首页 > 其他分享 >实验2

实验2

时间:2023-10-17 10:35:22浏览次数:27  
标签:include int number 实验 printf go main

#include<stdio.h>
#include<stdlib.h>
#include<time.h>
 
#define N 5
#define N1 374
#define N2 465
 
     int main()
 {
     int number;
     int i;
 
     srand(time(0));
 
     for (i = 0; i < N; i++) {
         number = rand() % (N2 - N1 + 1) + N1;
         printf("202383290376%04d\n", number);
    }
    return 0;
 }

#include<stdio.h>
#include<stdlib.h>
int main()
{
    char light;
    while(scanf("%c",&light)!=EOF)
    {
       switch(light)
       {
           case 'r':printf("stop!\n");break;
           case 'g':printf("go go go\n");break;
           case 'y':printf("wait a minute\n");break;
           defualt :printf("something must be wrong...\n");
       }
    }
    return 0;  
}

#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int main()
{
    srand(time(0));
    int x;
    int a=rand()%30+1;
    printf("猜猜2023年11月哪一天会是你的lucky day\n");
    printf("开始喽,你有三次机会,猜吧(1~30):");
    for (int i=1;i<=3;++i){
    scanf("%d",&x);
    if (x<a)
    printf("你猜的日期早了,你的lucky day还没到呢\n再猜(1~30):");
    else if (x>a)
    printf("你猜的日期晚了,你的lucky day已经过啦\n再猜(1~30):");
    else
    printf("哇,猜中了");
     }
     if (x != a)
         printf("次数用完啦,偷偷告诉你:11月,你的lucky day是%d号", a);
    return 0;  
}

#include<stdio.h>
#include<math.h>
int main()
  {
    int n, a;
    while(scanf("%d%d", &n, &a) != EOF)
    {
    double s = 0;
    double down = 0;
    for (int i = 1; i <= n; ++i) {
    down += pow(10, i - 1) * a;
    s += i / down;         
    }
    printf("n=%d,a=%d,s=%f", n, a, s);
    }
 }

#include<stdio.h>
  int main()
  {
    int i,j;
    for(i=1;i<=9;i++)
    {
        for(j=1;j<=i;j++)
        printf("%d*%d=%-5d",j,i,j*i);
        printf("\n");
    }
     
    
 }

 

标签:include,int,number,实验,printf,go,main
From: https://www.cnblogs.com/yukinoshita-/p/17769115.html

相关文章

  • 第二次实验
    任务1#include<stdio.h>#include<stdlib.h>#include<time.h>#defineN5#defineN1374#defineN2465intmain(){ intnumber; inti; srand(time(0));//以当前系统时间作为随机种子 for(i=0;i<N;++i){ number=rand()%(N2-N1+1)+N1; printf("......
  • 实验二
    #include<stdio.h>#include<math.h>intmain(){intn,a,up,down,i=1;doubles;while(scanf("%d%d",&n,&a)==2){while(i<=n){up=i;down+=a*pow(10,i-1);s+=up*1.......
  • 实验二
    task1code1#include<stdio.h>2#include<stdlib.h>3#include<time.h>4#defineN55#defineN13746#defineN24657intmain()8{9intnumber;10inti;11srand(time(0));//以当前系统时间作为随机种子12for(i=......
  • 实验2
    #include<stdio.h>#include<stdlib.h>#include<time.h>#defineN5#defineN1347#defineN2465intmain(){intnumber;inti;srand(time(0));for(i=0;i<N;++i){number=rand()%(N2-N1+1)+N1;......
  • 实验二
    实验二任务一代码1#include<stdio.h>2#include<stdlib.h>3#include<time.h>45#defineN56#defineN13747#defineN246589intmain(){10intnumber;11inti;12srand(time(0));1314for(i=1;i<......
  • 实验二
    任务一t.h1#ifndefT_H2#defineT_H3#include<iostream>4#include<string>5usingnamespacestd;6classT7{8public:9T(intx=0,inty=0);10T(constT&t);11T(T&&t);12~T();13voidset_m1......
  • 实验二
    1,源代码#include<stdio.h>#include<stdlib.h>#include<time.h>#defineN5#defineN1374#defineN2465intmain(){intnumber;inti;srand(time(0));//以当前系统时间作为随机种子for(i=0;i<N;++i){number=rand()%(N2-N1+1)+N1;......
  • 实验2
    #include<stdio.h>#include<stdlib.h>#include<time.h>#defineN5#defineN1374#defineN2465intmain(){intnumber;inti;srand(time(0));//以当前系统时间作为随机种子for(i=0;i<N;++i){number=rand()%(N2-N1+1)+N1;printf(......
  • 实验2
    task1问题一:line17作用:限制随机数范围在374~465之间问题二:程序功能:随时间变化,随机生成在202383290376374~202383290376465之间的数task21#include<stdio.h>2intmain(){3chara;4while(1){5a=getchar();6getchar();7if(a==EOF){8......
  • 实验1 类和对象_基础编程
    实验任务11.代码:1#include<iostream>2#include<string>3#include<vector>4#include<array>567//函数模板8//对满足特定条件的序列类型T对象,使用范围for输出9template<typenameT>10voidoutput1(constT&obj){11for(autoi:obj)......