Home > Back-end >  C prime Numbers determine (two-dimensional arrays, a custom function) for correction
C prime Numbers determine (two-dimensional arrays, a custom function) for correction

Time:09-27

# include & lt; stdio.h>
#include
#include
Int ss (int j, int a [j] [0])
{int flag=0, I;
for(i=2; I{if (a) [j] [0] % I==0)
{flag=1;
break;
}
}
return flag;
}

Int main (void)
{int I=0, j, a [100], [2], the count=0;
Srand (time (0));
for(; I<100; I++)
{j=I;
A [I] [0]=50 + rand () % 151;
A [I] [1]=ss (j, a [j] [0]).
If (a [I] [1]==0)
count++;
Printf (" a=% d \ [% d] [% d] t b=% d \ n ", I, a [I] [0], I, a [I] [1]).
}
Printf (" \ n there are % d a prime number in this group of data, ", count);
return 0;
}

CodePudding user response:

 # include & lt; stdio.h> 
#include
#include

Int ss (int num)
{
Int flag=0, I;
for(i=2; I{if (num % I==0)
{flag=1;
break;
}
}
return flag;
}

Int main (void)
{
//int I=0, j, a [100], [2], the count=0;
Int I=0, j, a [100], count=0;
int ret;

Srand (time (0));
for(; I<100; I++)
{
A [I]=50 + rand () % 151;
If ((ret=ss (a [I]))==0)
count++;
Printf (" a [% d]=% d % d \ n ", I, a [I], ret);
}
Printf (" \ n there are % d a prime number in this group of data, ", count);
return 0;
}

For your reference ~

Don't bother, in addition, the function parameters suggest the original poster to get to know more

CodePudding user response:

The
reference 1/f, confident boy reply:
 # include & lt; stdio.h> 
#include
#include

Int ss (int num)
{
Int flag=0, I;
for(i=2; I{if (num % I==0)
{flag=1;
break;
}
}
return flag;
}

Int main (void)
{
//int I=0, j, a [100], [2], the count=0;
Int I=0, j, a [100], count=0;
int ret;

Srand (time (0));
for(; I<100; I++)
{
A [I]=50 + rand () % 151;
If ((ret=ss (a [I]))==0)
count++;
Printf (" a [% d]=% d % d \ n ", I, a [I], ret);
}
Printf (" \ n there are % d a prime number in this group of data, ", count);
return 0;
}

For your reference ~

Don't bother, in addition, the function parameters suggest more to know about the building Lord

Ok, thank you
  • Related