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/05/04 09:05:57
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: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