experiment

[TASK1]
`#include<stdio.h>

include<stdlib.h>

include<time.h>

define N 5

int main(){
int number,i;
srand(time(0));
for(i = 0;i<N;i++){
number = rand()%65 + 1;
printf("2023833%01d\n",number);
}
return 0;
}
`

[TASK2]
`#include<stdio.h>

include<stdlib.h>

int main()
{
char ans;
printf("请输入\n");
while((ans=getchar())!=EOF){
getchar();
switch(ans)
{
case'r':printf("stop!\n");break;
case'g':printf("go go go\n");break;
case'y':printf("wait a minute\n");break;
default:printf("something must be wrong...\n");break;
}}
return 0;
}
`

[TASK3]
`#include<stdio.h>

include<stdlib.h>

int main()
{
int X,n;
srand(time(0));
X=rand()%31+1;
printf("猜猜2024年5月哪一天会是你的lucky day\n");
printf("开始喽,你有三次机会,猜吧(1~31)😊;
for(int i=1;i<=3;i++){
scanf("%d",&n);
if(n==X)
{
printf("哇,猜中了\n");return 0;}
else if(n<X)
printf("你猜的日期早了,你的lucky day还没到呢\n");
else
printf("你猜的日期晚了,你的lucky day在前面哦\n");}
printf("好吧,这是你的lucky day:%d",X);
return 0;
}
`

[TASK4]
#include<stdio.h> int main(){ int n,a; double s=0,x,y; while((scanf("%d %d",&n,&a))!=EOF){ for(int i=1;i<=n;i++){ x=0; for(int j=1;j<=i;j++) x = x*10+a; y=i*1.0/x; s+=y;} printf("n = %d,a = %d,s = %.6lf\n",n,a,s);} return 0; }

[TASK5]
#include<stdio.h> int main() { int i,j,product; for(i=1;i<=9;i++){ for(j=1;j<=i;j++){ product=i*j; printf("%dx%d = %d \t",j,i,product);} printf("\n");} return 0; }

[TASK6]
#include<stdio.h> int main() { int n,a,b=0,c,x,i,j,k; printf("input n:"); scanf("%d",&n); x=2*n-1; k=0; a=0; for(i=x;i>0;i=i-2) { for(j=0;j<i;j++) {printf(" O\t");} printf("\n"); for(k;k>=1;k--) {printf("\t");} k=b; for(j=0;j<i;j++) {printf("<H>\t");} printf("\n"); for(k;k>=1;k--) {printf("\t");} k=b; for(j=0;j<i;j++) {printf("I I\t");} printf("\n\n"); k+=1; b=k; for(k;k>=1;k--) {printf("\t");} k=b; } return 0; }

posted @ 2024-04-14 22:48  世界和平么  阅读(17)  评论(0编辑  收藏  举报