首页 > 其他分享 >实验2

实验2

时间:2023-03-20 23:23:43浏览次数:29  
标签:lf 截图 int scanf 实验 printf include

实验任务1

代码:

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

 

截图:

 

 

 实验任务2

代码:

#include<stdio.h>

int main()
{
    double x, y;
    char c1, c2, c3;
    int a1, a2, a3;
    scanf_s("%d %d %d", &a1, &a2, &a3);
    printf("a1=%d,a2=%d,a3=%d\n", a1, a2, a3);
    
    getchar();
    scanf_s("%c %c %c", &c1,1, &c2,1, &c3,1);
    printf("c1=%c,c2=%c,c3=%c\n", c1, c2, c3);

    scanf_s("%lf %lf", &x, &y);
    printf("x=%lf,y=%lf\n", x, y);
    return 0;
}

 

截图:

 

 

 

实验任务3

代码:

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

int main()
{
    double x, ans;
    while (scanf_s("%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_s("%lf", &C) != EOF)
    {
        F = 9 * C / 5 + 31;
        printf(" 摄氏度c=% .2f时,华氏度f= % .2f\n", C,F);
        printf("\n");
    }

    return 0;
}

 

截图:

 

 

 

 

 

实验任务4

代码:

截图:

实验任务5

代码:

#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int main()
{
    printf("猜猜2023年4月哪一天会是你的lucky day\n");
    int x, y;
    srand(time(0));
    y = rand() % 30 + 1;
    printf("开始喽,你有3次机会,猜吧(1~30):");
    
    for (int i = 1;; i++)
    {
        if (i > 1)    printf("再猜(1~30):");
        scanf_s("%d", &x);
        if (x == y) {
            printf("哇,猜中了:-)\n");
            break;
        }

        if (x < y) {
            printf("你猜的日期早了,你的lucky day还没到呢\n");
        }
    
        else {
            printf("你猜的日期晚了,你的lucky day已经过啦\n");
        }
        if (i > 2) {
            printf("次数用完啦。偷偷告诉你:4月,你的lucky day是%d号", y);
            break;
        }
    }

    system("pause");

    return 0;
}

 

截图:

 

实验任务6

代码:

#include<stdio.h>
#include<stdlib.h>
int main() {
    int column=1, line=1,value=1;
    for (column = 1; column <= 9; column++) {
        for (line = 1; line <= column; line++) {
            value = column * line;
            printf("%d*%d=%d  ", line, column,value);
        }
        printf("\n");
    }
    system("pause");
    return 0;
}

 

截图:

 

 

实验任务7

代码:

截图:

 

标签:lf,截图,int,scanf,实验,printf,include
From: https://www.cnblogs.com/gueal/p/17237589.html

相关文章

  • 蓝桥楼赛第9期-修复未正确实现的实验类 题解
    题目描述程序存放的位置/home/shiyanlou/lab.py;实验类名应该为Lab;实验对象中不能插入重复标签;Python中对象引用问题,尤其如复合对象list,dict,tuple的......
  • 实验2
    实验任务1代码:#include<stdio.h>#include<stdlib.h>#include<time.h>#defineN5#defineR1586#defineR2701intmain(){ intnumber; inti; srand(time(0)); for(......
  • 实验2 C语言输入输出和控制语句应用编程
    #include<stdio.h>#include<stdlib.h>#include<time.h>#defineN5#defineR1586#defineR2701intmain(){intnumber;inti;srand(time(0));......
  • 实验二
    实验任务1源代码:#include<stdio.h>#include<stdlib.h>#include<time.h>#defineN5#defineR1586#defineR2701intmain(){intnumber;inti;......
  • 开启一个 A/B 实验到底有多简单?
    更多技术交流、求职机会,欢迎关注字节跳动数据平台微信公众号,回复【1】进入官方交流群 火山引擎A/B测试平台DataTester孵化于字节跳动业务内部,在字节跳动,“万事皆A......
  • 心理学-进入心流状态的实验
    问题表现记录近期在改进的地方:如何让自己的心,静下来具体的表现:学习上,一点小小的任务完成,就会特别兴奋,导致不能继续做事;面对大量的学习规划任务,没有耐心去一步步的推进......
  • 软件测试实验-黑盒测试
     序号输入数据覆盖等价类输出12009、12、2236星期322022、3、14226星期132008、3、01316输入日期无效42022、6、e2422输入日期无......
  • 实验2
    实验任务2task1代码:#include<stdio.h>#include<stdlib.h>#include<time.h>#defineN5#defineR1586#defineR2701intmain(){ intnumber; inti; srand(ti......
  • 实验2
    1、实验任务1源代码及运行结果截图:#include<stdio.h>#include<stdlib.h>#include<time.h>#defineN5#defineR1586#defineR2701intmain(){intnumb......
  • 结对编程--保龄球实验
    1.实验目的通过结对编程完成保龄球计分程序2.实验过程:(1):首先我们两个一起商讨编写保龄球积分程序需要什么方法,经过十几分钟的商讨我们一致决定一共需要publicstaticint......