Here is my code.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
int i;
int j;
int x;
int y[100];
int b0 = 0, A0[100];
srand(time(NULL));
for (x = 0; x < 100; x ++)
{
y[x] = (rand()% 1000)+ 1;
}
int ans;
for (x = 0; x < 100; x ++)
{
ans = y[x] % 10;
if(x == 0)
{
printf("Frist group(Last for'0')\n");
}
if (ans == 0)
{
A0[b0] = y[x];
b0++;
}
}
for (int count0 = 0; count0 <= b0; count0 ++)
{
printf(" %d ", A0[count0]);
}
printf("\n\n");
system("pause");
return (0);
}
here is my output.
Frist group(Last for'0')
32766 1000 840 630 900 500 830 520 80 470 510 760
I don't know why when I run this program every time, the frist number is always a strange integer.
Can any one please help me, I want to know what is casuing this problem.
Thankyou very much.
Aucun commentaire:
Enregistrer un commentaire