#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define BUBBLE 5
int main()
{
int myArray[BUBBLE];
int i, j ,a , b, k;
int temp = 0;
int num;
int cunt;
cunt=0;
float floatType;
int integerType;
srand(time(NULL));
//Fill Array Randomlly
for (i = 0; i < BUBBLE; i ++)
{
num = rand() % BUBBLE + 1;
myArray[i] = num;
}
// For remove duplicate number
for (a = 0; i < BUBBLE; a++) {
for (b = a + 1; j < BUBBLE;) {
if (myArray[a] == myArray[b]) {
for (k = b; k < BUBBLE; k++) {
myArray[k] = myArray[k + 1];
}
BUBBLE--;
} else
b++;
}
}
// The Array Before Sort
for (i = 0; i < BUBBLE; i++)
{
printf("%d \n ",myArray[i]);
}
printf("After sort \n",myArray[i]);
//Sort Array With Bobble Algorhim
for(i = 0; i < BUBBLE; i++)
{
for (j = 0; j < BUBBLE-1; j++)
{
if (myArray[j] > myArray[j+1])
{
temp = myArray[j];
myArray[j] = myArray[j+1];
myArray[j+1] = temp;
cunt++;
}
}
}
//Print Array After Sort
for (i = 0; i < BUBBLE; i++)
{
printf("%d\n",myArray[i]);
}
// Count For How Many Swap
printf("the numbeer of pases is %d \n" ,cunt);
printf("Size of float: %ld bytes\n",sizeof(floatType));
system("PAUSE");
return 0;
}
I don't see a question.
To respond to your statement "I am trying to make my array without any duplicate number. "
My suggestion would be simply add "count" to every number and then increase "count" by one. Done.