首页 > 其他分享 >实验2

实验2

时间:2024-04-14 23:33:58浏览次数:22  
标签:include int 实验 printf input main

实验一

#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;
}

问题1:随机生成一个1-65之间的数字

问题2:随机生成5个班级学号

实验2

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

int main()
{
char input;
while(1)
{
    scanf("%c", &input);
    switch(input)
        {
        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;            
        }
    getchar();    
    }
    system("pause");
    return 0;
}
    

实验3

#include<stdio.h>
#include<stilib.h>
#include<time.h>
#define N 5

int main()
   {
       int number;
       
       srand(time(0));
       
       while(1)
       {
           for(i=1;i<=3,++i)
        scanf("%d",&number);
           
       }
    
    
} 

实验4

#include<stdio.h>

int main(){
    int n;
    double s;
    int i;
    int item;
    int a;
    int j;
    while (scanf("%d%d", &n, &a)!=EOF)
    {
        s=0.0;
    for(i=1;i<=n;++i){
       item=0;
       for(j=1;j<=i;++j)
        item=item*10+1;
    s+=(double)i/(a*item);}
    printf("n=%d,a=%d,s=%lf\n",n,a,s);
    
    }
    
    return 0;
    }

实验5

#include<stdio.h> 

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

实验6

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

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

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

}

标签:include,int,实验,printf,input,main
From: https://www.cnblogs.com/hzxh2005/p/18134913

相关文章

  • 实验2
    任务一:`#include<stdio.h>include<stdlib.h>include<time.h>defineN5intmian(){intnumber;inti;srand(time(0));for(i=0;i<N;++i){number=rand()%65+1;printf("20238331%04d\n",number);}return0;}`问题1:生成1到65的随机数问题2......
  • 原型设计实验
    原型设计工具比较分析:墨刀:适用领域:墨刀适用于快速原型设计和交互设计,特别适合移动应用和Web应用的设计。优点:界面简洁清晰,易于上手,适合初学者和团队合作。支持多种交互模式,如链接、滑动、弹出框等,可以较好地模拟用户操作流程。支持团队协作,可以多人同时编辑同一项目,方便团队......
  • 实验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; printf("20238331%04d\n",number); } return0;}......
  • 实验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;//控制随机数的范围从1~66printf("2023......
  • 实验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("2023833%04d\n",number); } ret......
  • 实验二
    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("202......
  • 实验二。
    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 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); } 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;//生成一个1-65之间的随机数printf("20238331%04d\n",......
  • 第二次实验
    练习一:line15是在1~65的范围内随机取数这个程序生成202383310001~202383310065之间的学号练习二:include<stdio.h>intmain(){charcolor;while(scanf("%c",&color)!=EOF){ switch(color){ case'r':printf("stop!\n"); break; case'g�......