首页 > 其他分享 >实验二

实验二

时间:2024-04-14 22:01:44浏览次数:19  
标签:include return int pause 实验 printf main

项目1
代码
`#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);

}

system("pause");
return 0;

}`
运行结果

为了生成65以内的数字
生成数位正确的学号

项目2
代码
`#include<stdio.h>

include<stdlib.h>

int main(){
char color;
while(1){
scanf("%c",&color);

switch(color){
    case 'r':printf("stop!\n");break;
    case 'g':printf("go go go\n");break;
    case 'y':printf("wait a minute\n");break;    
    default:printf("domething must be wrong...\n");break;    
}
getchar();

}

system("pause");
return 0;

}`
运行结果

项目3
代码
`#include<stdio.h>

include<stdlib.h>

include<time.h>

int main(){
int ld, d;
int i;

srand( time(0));
ld = rand()%31 + 1;

printf("猜猜2024年5月哪一天会是你的幸运日\n开始喽,你有三次机会,猜吧(1~31:");

    for(i = 1;i <= 3;i++){
        scanf("%d",&d);
        if(d < ld){
            printf("你猜的日期早了,你的幸运日还没到呢\n:");
            if(i <= 2){
                printf("\n再猜(1~31):");
            }
        }
        if(d > ld){
            printf("你猜的日期晚了,你的幸运日在前面哦\n");
            if(i <= 2){
                printf("\n再猜(1~31):");
                }    
        }
        if(d == ld){
            printf("\n哇,猜中了");
			system("pause");
            return 0;
        }    
    } 
if(d != ld)
    printf("\n次数用完啦,偷偷告诉你,5月你的幸运日是%d号\n",ld); 


system("pause");
return 0;

}`
运行结果

项目4
代码
`#include<stdio.h>

include<stdlib.h>

double func(int n, int a);
int main()
{
int n, a;
double s;
while(1){
scanf("%d%d",&n,&a);
s=func(n,a);
printf("n = %d,a = %d,s = %lf\n",n,a,s);
}
return 0;
}
double func(int n, int a)
{
int i,b=0;
double s=0.0;
for(i=1;i<=n;i++){
b=b10+a;
s=s+1.0
i/b;
}

system("pause");
return s;

}`
运行结果

项目5
代码
`#include<stdio.h>

include<stdlib.h>

int main(){
int i,j;

for(i=1;i<=9;i++){
    for(j=1;j<=i;j++){
        printf("%d*%d=%-3d",j,i,j*i);
    }
    printf("\n");
}
system("pause");
return 0;

}`
运行结果

项目6
代码
`#include <stdio.h>

include<stdlib.h>

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

for (i=0;i<n;i++)
{
    for (j=0;j<i; j++){
        printf("\t") ;
}
for (k=2*(n-i)-1;k>0;k--)
{
    printf(" O \t");
}
printf("\n");

for (j=0; j<i; j++)
{
    printf("\t");
}
for (k=2*(n-i)-1;k>0;k--)
{
    printf("<H>\t");
}
printf("\n");

for (j=0; j<i; j++)
{
    printf("\t");
}
for (k=2*(n-i)-1;k>0;k--)
{
    printf("I I\t");
}
printf("\n");

}

system("pause");
return 0;

}`
运行结果

标签:include,return,int,pause,实验,printf,main
From: https://www.cnblogs.com/amiens/p/18134770

相关文章

  • 实验二
    #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); } return0;}#i......
  • 实验2 C语言分支与循环基础应用编程
    任务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;//生成一个1-65之间的随机数printf("20238331%04d\n&q......
  • 实验二
    任务一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);}return0;}问题一:在一到六十五之......
  • 实验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......