1.编程实现:输出0-100的平方根表。
发布网友
发布时间:2022-04-23 08:07
我来回答
共3个回答
热心网友
时间:2022-06-18 03:39
0 分的,看来只有我给你做了。。。
#include<stdio.h>
#include<math.h>
int main()
{
int n;
double m;
for(n=0;n<=100;n++){
printf("%d=>%.4f ",n,sqrt(n));
if((n+1)%5==0)printf("\n");
}
getchar();
return 0;
}
===================================
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<time.h>
#define r100 rand()%NN
#define r4 rand()%4
#define r50 rand()%(NN/2)
int main()
{
int a,b,c,i,j,aa[25]={1};
int ans,s,score=0,k=0,hour,mini,sec,NN;
clock_t start,end;
char ch[4][4]={"+","-","x","÷"},ag;
srand(time(0));
begin: printf("请输入测验数字大小范围(100表示100以内):");
scanf("%d",&NN);
printf(">>>>>>>>>>>>>>你将要进行%d以内测验!<<<<<<<<<<<<<<<<<<<<<<\n",NN);
system("pause");
system("cls");
for(i=1;i<6;i++)printf("\n");
printf(" ####################################################################\n");
printf(" ####*************************准备好了么??*********************####\n");
printf(" ####************************Ready, Go,Go,Go!*******************####\n");
printf(" ####********好好学习*********Good good Study!*****天天向上*****####\n");
printf(" ####****************************Day Day Up!*********************####\n");
printf(" ####################################################################\n");
system("pause");
start=clock();
do {
k++;
a=r100;
b=r100;
c=r4;
if(3==c)
{ aa[1]=a;
for(i=2,j=2;i<=a/2;i++)
if(a%i==0){aa[j]=i;j++;}
do b=aa[rand()%j];
while(b==0);
}
if(1==c)b=rand()%a;
if(2==c){a=r50;b=rand()%(NN/a);}
if(0==c)b=rand()%(NN-a);
switch(c){
case 0:s=a+b;break;
case 1:s=a-b;break;
case 2:s=a*b;break;
case 3:s=a/b;break;
}
printf("(%d). %d %s %d =",k,a,ch[c],b);
scanf("%d",&ans);
if(ans==s)printf("(√)得分:%d\n",score+=2);
else printf("(×)得分:\n",score);
}
while(k<50);
end=clock();
hour=0;
mini=0;
sec=(end-start)/1000;
if(sec>59)
{
if(sec>=3600){hour=sec/3600;mini=(sec-hour*3600)/60;sec=sec%60;}
else {hour=0;mini=sec/60;sec=sec%60;}
}
printf("总用时:%d小时%d分%d秒\n总得分:%d\n",hour,mini,sec,score);
if(score<60){
printf("你很聪明,不过基础太差,你还需要努力噢,加油!加油!加油!");
printf("不服,再来一遍?(Y/N):") ;
fflush(stdin);
ag=getchar();
if(ag=='Y'||ag=='y')goto begin;
}
system("pause");
fflush(stdin);
printf("是否再来一遍?(Y/N):");
ag=getchar();
if(ag=='Y'||ag=='y')goto begin;
return 0;
}
热心网友
时间:2022-06-18 03:40
0
分的,看来只有我给你做了。。。
#include<stdio.h>
#include<math.h>
int
main()
{
int
n;
double
m;
for(n=0;n<=100;n++){
printf("%d=>%.4f
",n,sqrt(n));
if((n+1)%5==0)printf("\n");
}
getchar();
return
0;
}
===================================
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<time.h>
#define
r100
rand()%NN
#define
r4
rand()%4
#define
r50
rand()%(NN/2)
int
main()
{
int
a,b,c,i,j,aa[25]={1};
int
ans,s,score=0,k=0,hour,mini,sec,NN;
clock_t
start,end;
char
ch[4][4]={"+","-","x","÷"},ag;
srand(time(0));
begin:
printf("请输入测验数字大小范围(100表示100以内):");
scanf("%d",&NN);
printf(">>>>>>>>>>>>>>你将要进行%d以内测验!<<<<<<<<<<<<<<<<<<<<<<\n",NN);
system("pause");
system("cls");
for(i=1;i<6;i++)printf("\n");
printf("
####################################################################\n");
printf("
####*************************准备好了么??*********************####\n");
printf("
####************************Ready,
Go,Go,Go!*******************####\n");
printf("
####********好好学习*********Good
good
Study!*****天天向上*****####\n");
printf("
####****************************Day
Day
Up!*********************####\n");
printf("
####################################################################\n");
system("pause");
start=clock();
do
{
k++;
a=r100;
b=r100;
c=r4;
if(3==c)
{
aa[1]=a;
for(i=2,j=2;i<=a/2;i++)
if(a%i==0){aa[j]=i;j++;}
do
b=aa[rand()%j];
while(b==0);
}
if(1==c)b=rand()%a;
if(2==c){a=r50;b=rand()%(NN/a);}
if(0==c)b=rand()%(NN-a);
switch(c){
case
0:s=a+b;break;
case
1:s=a-b;break;
case
2:s=a*b;break;
case
3:s=a/b;break;
}
printf("(%d).
%d
%s
%d
=",k,a,ch[c],b);
scanf("%d",&ans);
if(ans==s)printf("(√)得分:%d\n",score+=2);
else
printf("(×)得分:\n",score);
}
while(k<50);
end=clock();
hour=0;
mini=0;
sec=(end-start)/1000;
if(sec>59)
{
if(sec>=3600){hour=sec/3600;mini=(sec-hour*3600)/60;sec=sec%60;}
else
{hour=0;mini=sec/60;sec=sec%60;}
}
printf("总用时:%d小时%d分%d秒\n总得分:%d\n",hour,mini,sec,score);
if(score<60){
printf("你很聪明,不过基础太差,你还需要努力噢,加油!加油!加油!");
printf("不服,再来一遍?(Y/N):")
;
fflush(stdin);
ag=getchar();
if(ag=='Y'||ag=='y')goto
begin;
}
system("pause");
fflush(stdin);
printf("是否再来一遍?(Y/N):");
ag=getchar();
if(ag=='Y'||ag=='y')goto
begin;
return
0;
}
热心网友
时间:2022-06-18 03:40
#include<math.h>
#include<stdio.h>
void main(int argc,void **argv)
{
int i=0;
double result=0;
for(;i<101;i++)
{
result=sqrt(i);
printf("%d 的平方根=%f",i,result);
}
}