# 实验2

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

#define N 5
#define R1 586
#define R2 701

int main()
{
int number,i;

srand( time(0) );

for(i=0;i<N;++i)
{
number=rand()%(R2-R1+1)+R1;
printf("20228330%04d\n",number);
}

return 0;
} 

2.功能为生成5个尾号为586到701之间的学号.

#include <stdio.h>

int main()
{
double x,y;
char ans,c1,c2,c3;
int a1,a2,a3;

scanf("%d%d%d",&a1,&a2,&a3);
printf("a1=%d,a2=%d,a3=%d\n",a1,a2,a3);

scanf("%c%c%c%c",&ans,&c1,&c2,&c3);
printf("c1=%c,c2=%c,c3=%c\n",c1,c2,c3);

scanf("%lf,%lf",&x,&y);
printf("x=%lf,y=%lf\n",x,y);

return 0;
} 

#include <stdio.h>
#include <math.h>

int main()
{
double x,ans;

while(scanf("%lf",&x) != EOF)
{
ans=pow(x,365);
printf("%.2f的365次方：%.2f\n",x,ans);
printf("\n");
}

return 0;
} 

#include <stdio.h>
#include <math.h>

int main()
{
double C,F;

while(scanf("%lf",&C) != EOF)
{
F=1.8*C+32;
printf("摄氏度C=%.2f时，华氏度F=%.2f\n",C,F);
printf("\n");
}

return 0;
} 

#include <stdio.h>

int main()
{
char x,ans;
while(scanf("%c%c",&x,&ans) !=EOF){
switch(x){
case 'r':printf("stop\n");break;
case 'g':printf("go\n");break;
case 'y':printf("wait\n");break;
default:printf("something must be wrong\n");
}
}
return 0;
} 

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main()
{
int number,data,i;
srand((unsigned int)time(NULL));
number=rand()%30+1;
printf("猜猜今年4月哪天是你的幸运日\n");

for(i=1;i<=3;i++){
scanf("%d",&data);
if(data==number){
printf("猜中了\n");
break;
}
if(data<number)
printf("早了呢\n");
if(data>number)
printf("晚了呢\n");
printf("你还有%d次机会\n",3-i);
}
if(data!=number)
printf("偷偷告诉你，你的幸运日是%d号\n",number);

return 0;
} 

#include <stdio.h>
#include <stdlib.h>

int main()
{
int x,y;
for(y=1;y<10;y++){
for(x=1;x<=y;x++){
printf("%d*%d=%d\t",x,y,x*y);
}
printf("\n");
}

return 0;
} 

#include <stdio.h>
#include <stdlib.h>

int main()
{
int n,i,x,y;
scanf("%d",&n);
y=1;
for(;n!=0;n--){
for(x=1;x<y;x++){
printf("\t");
}
for(i=1;i<=(2*n-1);i++){
printf(" o \t");
}
printf("\n");
for(x=1;x<y;x++){
printf("\t");
}
for(i=1;i<=(2*n-1);i++){
printf("<H>\t");
}
printf("\n");
for(x=1;x<y;x++){
printf("\t");
}
for(i=1;i<=(2*n-1);i++){
printf("I I\t");
}
printf("\n");
y++;
}

return 0;
} 

posted @ 2023-03-17 11:39  15278883663  阅读(10)  评论(0编辑  收藏  举报