C 语言 急 wirte a program that generates 100 randomly numbers (
来源:学生作业帮 编辑:灵鹊做题网作业帮 分类:综合作业 时间:2024/05/06 16:30:45
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)
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)
#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
#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
C 语言 急 wirte a program that generates 100 randomly numbers (
Write a program that generates 4-,10-,or 20-sided dice.
关于C语言的一道题原题:Write a program that requests a type double numb
C语言字符串计数Write a program that reads an English statement from
英文的~1.When a vaccination program generates a positive extern
英语翻译A program that can do nothing more than spit out numbers
求解jave题,急,write a program that will continu
C语言程序write a program to display a Christmas tree
C语言作业,Task:Program a quiz game with at least 4 questions.For
Given that a,b,c are three consecutive odd numbers and b*b*b
English Class room is a program that
Write a program which asks the user for four numbers(Python)