首页 > 其他分享 >实验二

实验二

时间:2023-03-19 20:22:35浏览次数:35  
标签:include int scanf 实验 printf line main

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

#define N 5
#define R1 586
#define R2 701
int main()
{
    int number;
    int i;
    srand( time(0) );
    for(i=0; i<N; ++i)
    {
        number = rand()%(R2-R1+1)+R1;
        printf("20228330%04d\n", number); 
    }
    return 0;

生成一个与时间有关的随机数

随机打出某个学生的学号

#include<stdio.h>

int main()
{
double x, y;
char c1, c2, c3;
int a1, a2, a3;

scanf("%d %d %d\n",&a1, &a2, &a3);//错误一行

 



printf("a1=%d,a2=%d,a3=%d\n",a1, a2,a3);

scanf("%c%c%c",&c1,&c2,&c3);
printf("c1=%c,c2=%c,c3=%c\n",c1, c2, c3);

getchar();
scanf("%lf%lf",&x,&y);
printf("x=%lf,y=%lf\n",x,y);

return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{
    double x, ans;
    
    while(scanf("%lf",&x) !=EOF)
    {
        ans=pow(x,365);
        printf("%.2f的365次方:%.2f\n",x, ans);
        printf("\n");
    }
    
    return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{
    double C, F;
    
    while(scanf("%lf",&C) !=EOF)
    {
        F=(9*C)/5+32;
        printf("%摄氏度c=%.2f时,华氏度f=%.2f",C, F);
        printf("\n");
        printf("\n");
    }
    
    return 0;
}

#include<stdio.h>

int main()
{
    char ans;
    while(scanf("%c",&ans)!=EOF)
    {
        switch(ans){
            case'y':printf("wait a minute\n");break;
            case'g':printf("go go go\n");break;
            case'r':printf("stop\n");break;
            default:printf("something must be wromng\n");break;
        }
        getchar();
    }
    return 0;
}

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

#define N 5
#define R1 586
#define R2 701
int main()
{
    int number, x, j;
    int flag;
    flag=1;
    srand(time(0));
    number = rand() % (R2 - R1 + 1);
    printf("猜猜2023年4月哪一天是你的lucky day\n");
    printf("开始喽,你有三次机会,猜吧(1~30):"); 
    for(x=1;x<4;x++){
        scanf("%d", &j);
        if(number==j){
            printf("哇,猜中了\n");
            flag=0;
            continue;
        }
        else if(number<j){
            printf("你猜的日期晚了,你的lucky day已经过啦\n");
            printf("再猜(1~30):");
            continue;
        } 
        else (number>j);{
            printf("你猜的日期早了,你的lucky day还没到呢\n");
            printf("再猜(1~30):");
            continue; 
        }
    }
    if (flag=1)
    printf("次数用完啦。偷偷告诉你:4月你的lucky day是%d\n",number);
    
    return 0;
}

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

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



    return 0;
}

#include<stdio.h>
#include<math.h>

int main()
{
    int n,i,j,a,line;
    printf("请输入行数line:");
    scanf("%d", &line);
    n=2*line-1;
        for (i = n; i >=0;i=i-2) {
            for (a = 0; a <=(n- i)/2; a++) {
                printf("\t");
            }
            for (j = 1; j <= i; j++) {
                printf("  o \t");
            }
            printf("\n");

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

 

标签:include,int,scanf,实验,printf,line,main
From: https://www.cnblogs.com/chennana/p/17234124.html

相关文章

  • 实验二
    实验任务1#include<stdio.h>#include<stdlib.h>#include<time.h>#defineN5#defineR1586#defineR2701intmain(){intnumber;inti;sr......
  • 实验一 密码引擎-1-OpenEuler-OpenSSL编译
    任务详情安装Ubuntu和OpenEuler虚拟机下载最新的OpenSSL源码(1.1版本)用自己的8位学号建立一个文件夹,cd你的学号,用pwd获得绝对路径参考https://www.cnblogs.com/roc......
  • 实验2
    1代码:#include<stdio.h>#include<stdlib.h>#include<time.h>#defineN5#defineR1586#defineR2701intmain(){intnumber;inti;s......
  • 实验2
    实验任务11#include<stdio.h.>2#include<stdlib.h>3#include<time.h>45#defineN56#defineR15867#defineR270189intmain()10{11......
  • 实验2
    实验任务1程序源码#include<stdio.h>#include<stdlib.h>#include<time.h>#defineN5#defineR1586#defineR2701intmain(){intnumber;inti;......
  • 实验报告1
     ......
  • 实验二
    test1#include<stdio.h>#include<stdlib.h>#include<time.h>#defineN5#defineR1586#defineR2701intmain(){intnumber;inti;sran......
  • 实验二
    实验任务一  1:随机生成一个586和701之间的数字 2:随机生成五个最后四位在586和701之间的数字 实验任务二#include<stdio.h>intmain(){doublex,y;......
  • 实验2
    实验任务1源代码#include<stdio.h>#include<stdlib.h>#include<time.h>#defineN5#defineR1586#defineR2701intmain(){intnumber;inti;......
  • pta python实验1-3
    7-1HelloWorld这是学习每种程序设计语言的第一个实例。‪‬‪‬‪‬‪‬‪‬‮‬‪‬‫‬‪‬‪‬‪‬‪‬‪‬‮‬‭‬‫‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‪‬输出Hell......