首页 > 其他分享 >实验二

实验二

时间:2024-04-14 21:24:51浏览次数:10  
标签:main return int else 实验 printf include

任务一

include <stdio.h>

include<stdlib.h>

include<time.h>

define N 5

int main()
{
int number;
int i;
srand(time(0));

 for(i=0;i<N;++i){ 	

 number=rand()%65+1; 	

  printf("20238331%04d\n",number); } 

return 0;
}
问题一:在一到六十五之间随机输出整数
问题二:生成五个以20238331开头的十二位数随机学号,随机数前两位为零
任务二

include <stdio.h>

int main()
{
char c;
while((c=getchar())!=EOF){

if(c=='r')
  printf("stop!\n");
else if(c=='g')
  printf("go go go\n");
else if(c=='y')
  printf("wait a minute\n");
else
  printf("something must be wrong\n");
getchar();

}
return 0;
}

任务三

include <stdio.h>

include <stdlib.h>

include <time.h>

int main()
{
int day,chance=3;
srand(time(0));
int luckday=rand()%31+1;
printf("猜猜哪一天是你的luckday\n") ;
do{
scanf("%d",&day);
if(day==luckday)
{
printf("恭喜你,猜对了\n");
break;
}
else if(day<luckday)
{printf("你猜的日期早了\n");}
else
{ printf("你猜的日期晚了\n");}
chance--;
}
while (chance>0);
if(chance<=0){
printf("你已经没有机会了,偷偷告诉你五月的幸运日是%02d号",luckday);
}
system("pause");
return 0;
}
任务四

include <stdio.h>

include <stdlib.h>

int main()
{
int a,n,y,z;
double s;
while(scanf("%d%d",&n,&a)!=EOF){
y=a;
s=0.0;
for(z=1;z<=n;z++){
s=s+(double)z/a;
a=a+a*10;
}
printf("n= %d,a= %d,s=%f\n",n,y,s);
}
system("pause");
return 0;
}

任务五

include<stdio.h>

include<math.h>

int main(){
for(int i=1;i<=9;i++){
for(int j=1;j<=i;j++){
printf("%dx%d=%d\t",j,i,j*i);
}
printf("\n");
}
return 0;
}

任务六

include <stdio.h>

include <stdlib.h>

int main()
{
int n,i,y,z;
printf("input n:");
scanf("%d",&n);

for(i=0;i<n;++i){
    for (y=1;y<=i;++y)
       printf("\t");
    for(z=2*(n-i)-1;z>0;--z)
       printf("  O\t");
       printf("\n");
    for(y=1;y<=i;++y)
       printf("\t");
    for(z=2*(n-i)-1;z>0;--z)
       printf(" <H>\t");
       printf("\n");
    for(y=1;y<=i;++y)
       printf("\t");
    for(z=2*(n-i)-1;z>0;--z)
       printf(" I I\t");
       printf("\n");}
 system("pause");
return 0;
}


标签:main,return,int,else,实验,printf,include
From: https://www.cnblogs.com/lmj999/p/18134698

相关文章

  • 实验2
    实验一#include<stdio.h>#include<stdlib.h>#include<time.h>#defineN5intmain(){intnumber;inti;srand(time(0));for(i=0;i<N;++i){number=rand()%65+1;printf("20238331%04d\n",number);......
  • 实验2
    `#include<stdio.h>include<stdlib.h>include<time.h>defineN5intmain(){intnumber;inti;srand(time(0));//以当前系统时间作为随机种子for(i=0;i<N;++i){number=rand()%65+1;printf("20238331%04d\n",numbe......
  • 实验2-
    task1.c点击查看代码#include<stdio.h>#include<stdlib.h>#include<time.h>#defineN5intmain(){intnumber;inti;srand(time(0));//以当前系统时间作为随机种子for(i=0;i<N;++i){number=rand()%65+1;printf("20238331%04d\n"......
  • 实验2
    实验2.1#include<stdio.h>#include<stdlib.h>#include<time.h>#defineN5intmain(){intnumber;inti;srand(time(0));for(i=0;i<N;++i){number=rand()%65+1;printf("20238331%04d\n",number......
  • 实验2
    task1点击查看代码#include<stdio.h>#include<stdlib.h>#include<time.h>#defineN5intmain(){intnumber;inti;srand(time(0));//以当前系统时间作为随机种子for(i=0;i<N;++i){number=rand()%65+1;printf("20238331%04d\n"......
  • 实验一-密码引擎-3-加密API研究
    密码引擎API的主要标准和规范包括:1微软的CryptoAPI2RAS公司的PKCS#11标准3中国商用密码标准:GMT0016-2012智能密码钥匙密码应用接口规范,GMT0018-2012密码设备应用接口规范等研究以上API接口,总结他们的异同,并以龙脉GM3000Key为例,写出调用不同接口的代码,提交博客链接和代......
  • 实验2 C语言分支与循环基础应用编程
    #include<stdio.h>#include<stdlib.h>#include<time.h>#defineN5intmain(){intnumber;inti;srand(time(0));for(i=0;i<N;++i){number=rand()%65+1;printf("20238331%04d\n",number);}syste......
  • 实验一-密码引擎-3-加密API
    实验一-密码引擎-3-加密API研究任务详情密码引擎API的主要标准和规范包括:微软的CryptoAPIRAS公司的PKCS#11标准中国商用密码标准:GMT0016-2012智能密码钥匙密码应用接口规范,GMT0018-2012密码设备应用接口规范等研究以上API接口,总结他们的异同,并以龙脉GM3000Key为例,写出......
  • 实验一-密码引擎-3-加密API研究
    密码引擎API的主要标准和规范包括:微软的CryptoAPIRAS公司的PKCS#11标准中国商用密码标准:GMT0016-2012智能密码钥匙密码应用接口规范,GMT0018-2012密码设备应用接口规范等研究以上API接口,总结他们的异同,并以龙脉GM3000Key为例,写出调用不同接口的代码,提交博客链接和代码链......
  • 实验2C语言分支与循环基础应用编程
    #include<stdio.h>#include<stdlib.h>#include<time.h>#defineN5intmain(){intnumber;inti;srand(time(0));for(i=0;i<N;++i){number=rand()%65+1;printf("20238331%04d\n"......