首页 > 其他分享 >实验2

实验2

时间:2022-10-25 22:13:52浏览次数:43  
标签:include int number 实验 printf main define


#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() % 500 + 1; printf("20228329%04d\n", number); } return 0; }

 

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

int main()
{
    int number;
    int n, i;
   

    srand(time(0));
    number = rand() % 30 + 1;
    printf("猜猜那一天会是你的Lucky day\n");
    printf("开始喽,你有三次机会,猜吧(1~30)\n");
    for (i = 1; i <= 3; i++)
    {
        scanf("%d", &n);

        if (n == number)
        {
            printf("你猜中了");
            break;
        }
        if (n < number)
        {
            printf("你猜的日期早了,Lucky day还没到呢\n");
        }
        if (n > number)
        {
            printf("你猜的日期晚了,Lucky day已经过啦\n");
        }
        if (i == 3) {
            printf("次数用光啦,偷偷告诉你:11月,你的Lucky day是%3d号\n", number);
            break;
        }
        if (i <= 2) {
            printf("再猜:\n");
        }
    }


    return 0;
}

#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
int main()
{
    char x;

    while (scanf(" %c", &x ) != EOF)
    {

    switch (x)
    {
    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 wrong...");

    }


    }

    return 0;
}

 

#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int main()
{
    int a,n,i;
    double s=0,t=0;
    while (scanf("%d,%d",&n,&a)!=EOF)
    {
        printf("n=%d,a=%d,", n, a);
        for (i = 1; i <= n; ++i)
        {
            t = t * 10 + a;
            s = s + i / t;
        }
        printf("s=%lf\n", s);
        s = 0;
        t = 0;

    }

    return 0;
}

#include<stdio.h>
int main()
{
    int x, y;
    for (x = 1; x <= 9; x++)
    {

        for (y = 1; y <= x; y++)
            printf("%dx%d=%2d", x, y, x * y);
        printf("\n");
    }


    return 0;

}

 

#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
int main()
{
    int i, m, n;
    scanf("%d", &n);
    for (i = 1; i <= n; i++) {
        for (m = 1; m < i; m++) {
            printf(" \t");
        }
        for (m = 1; m <= 2 * (n - i) + 1; m++) {
            printf(" O \t");
        }
        printf("\n");
        for (m = 1; m < i; m++) {
            printf(" \t");
        }
        for (m = 1; m <= 2 * (n - i) + 1; m++) {
            printf("<H>\t");
        }
        printf("\n");
        for (m = 1; m < i; m++) {
            printf(" \t");
        }
        for (m = 1; m <= 2 * (n - i) + 1; m++) {
            printf("I I\t");
        }
        printf("\n");
        printf("\n");
    }
    return 0;
}

 

标签:include,int,number,实验,printf,main,define
From: https://www.cnblogs.com/0253yyf/p/16824524.html

相关文章

  • 实验3 数组、指针与现代c++标准库
    实验任务5#include"Info.hpp"#include<iostream>#include<string>#include<vector>intmain(){strings1,s2="continue";inti=0,n=0;intcon......
  • 实验7:基于REST API的SDN北向应用实践
    实验7:基于RESTAPI的SDN北向应用实践一、实验目的1.下载虚拟机软件OracleVisualBox或VMware;2.在虚拟机中安装Ubuntu20.04Desktopamd64,并完整安装Mininet、OpenDayli......
  • p28-p30程序固化实验(UG585)
    1、PS_POR_B是PS的复位引脚,POR=poweronreset上电硬复位,non_POR软复位包括PS_SRST_B管脚和其他内部复位。硬复位可以读取bootstrappins上的数据,然后复位psclockPLL......
  • 实验7:基于REST API的SDN北向应用实践
    实验7:基于RESTAPI的SDN北向应用实践一、实验目的能够编写程序调用OpenDaylightRESTAPI实现特定网络功能;能够编写程序调用RyuRESTAPI实现特定网络功能。二、......
  • 实验7:基于REST API的SDN北向应用实践
    一、基础要求1.编写Python程序,调用OpenDaylight的北向接口实现以下功能(1)利用Mininet平台搭建下图所示网络拓扑,并连接OpenDaylight;(2)下发指令删除s1上的流表数据。#!......
  • 实验7:基于REST API的SDN北向应用实践
    一、实验要求(一)基础要求1.编写Python程序,调用OpenDaylight的北向接口实现以下功能(1)利用Mininet平台搭建下图所示网络拓扑,并连接OpenDaylight;(2)下发指令删除s1上的流表......
  • 实验7:基于REST API的SDN北向应用实践
    一、实验目的能够编写程序调用OpenDaylightRESTAPI实现特定网络功能;能够编写程序调用RyuRESTAPI实现特定网络功能。二、实验环境OracleVisualBox;Ubuntu22.04......
  • 实验7:基于REST API的SDN北向应用实践
    一、实验目的能够编写程序调用OpenDaylightRESTAPI实现特定网络功能;能够编写程序调用RyuRESTAPI实现特定网络功能。二、实验环境下载虚拟机软件OracleVisualBox或......
  • 实验三
    实验五hpp#pragmaonce#include<iostream>#include<iomanip>#include<string>usingnamespacestd;classInfo{public:Info(stringname0,stringcontact0,......
  • 实验三
    task5://info.hpp#include<iostream>#include<string>usingnamespacestd;classinfo{private:stringnickname,contact,city;intn;staticin......