C 语言 急 wirte a program that generates 100 randomly numbers (between 0 and 1000),shows is it prime or not,also reads the number digits,coputes multiplication(mulp) and sum of the computed digits,and divides mulp/sum.displays results as a table:N

来源:学生作业帮助网 编辑:作业帮 时间:2024/08/26 13:43:01
C 语言 急 wirte a program that generates 100 randomly numbers (between 0 and 1000),shows is it prime or not,also reads the number digits,coputes multiplication(mulp) and sum of the computed digits,and divides mulp/sum.displays results as a table:N
xTQk0+GGn:^BIvaliكb+1Ir03џ8u UB>tzy~ ֪Т IR + $hA5PSͥ6̥]II69^Z@,a%Ai e#QZ0|  &Tݸ8USZK̄EEOГLU9a9[̷:f߫M]ሆ9 y)\]~995$ kohEC۰9 BZ! q\O>!_ eeK8q֐8 KǛoY;hKٚ"8Enfenf;R7: _[ AV'#Ǧ4q/7}

C 语言 急 wirte a program that generates 100 randomly numbers (between 0 and 1000),shows is it prime or not,also reads the number digits,coputes multiplication(mulp) and sum of the computed digits,and divides mulp/sum.displays results as a table:N
C 语言 急
wirte a program that generates 100 randomly numbers (between 0 and 1000),shows is it prime or not,also reads the number digits,coputes multiplication(mulp) and sum of the computed digits,and divides mulp/sum.displays results as a table:
Num :prime:digits mulp :digits sum:mulp/sum
443 yes 48 11 4.3636
use functions isprime(n),getsum(n),and get getmultiplication(n)

C 语言 急 wirte a program that generates 100 randomly numbers (between 0 and 1000),shows is it prime or not,also reads the number digits,coputes multiplication(mulp) and sum of the computed digits,and divides mulp/sum.displays results as a table:N
#include
#include
#include
#include
unsigned int getRandNumber(unsigned int min,unsigned int max)
{
return rand()%(max-min)+min;
}
int isPrime(unsigned int n)
{
int i,k=(int)sqrt(n);
for(i=2;i1;
}
unsigned int getSum(unsigned int n)
{
unsigned int sum=0;

do
{
sum += n%10;
n /= 10;
}while(n);

return sum;
}
unsigned int getMultiplication(unsigned int n)
{
unsigned int muti=1;

do
{
muti *= n%10;
n /= 10;
}while(n);

return muti;
}
int main(int argc, char *argv[])
{
int i,n;
// reset rand seed
srand(time(NULL));

// print the title
printf("Num :\tprime:\tdigits mulp :\tdigits sum:\tmulp/sum\n");

// generate 1000 randomly number
for(i=1;i