首页 > 其他分享 >实验二

实验二

时间:2023-11-05 16:37:17浏览次数:31  
标签:main space int -- 实验 printf include

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

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

#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int main()
{
    int day;
    srand(time(0));
    day=rand()%30+1;
    int chance;
    int guess;
    printf("猜猜2023年11月哪一天会是你的lucky day,你有三次机会:");
    for(chance=3;chance>0;chance--){
        scanf("%d",&guess);
        if(guess==day){
            printf("right!\n");
            return 0;
        }
        else if(guess>day){
            printf("too late!\n");
        }
        else if(guess<day){
            printf("too early!\n");
        }
        else{
            printf("再猜:");
        }
        
        
    }
    return 0;
    
    
    
    
 } 

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

#include<stdio.h>
int main()
{
    int n=9;
    int i=1;
    int j;
    while(i<=n){
        j=1;
        while(j<=i){
            if(j*i<10){
                printf("%d%d=%d",j,i,j*i);
            }
            else{
                printf("%d%d=%d",j,i,j*i);
            }
            j++;
        }
        i++;
        printf("\n");
    }
    return 0;
    
 } 

#include<stdio.h>
int main()
{
    int n;
    scanf("%d",&n);
    int n1=n;
    
    int s;
    int space;
    
    for(n=n;n>0;n--){
        for(space=n1-n;space>0;space--){
            printf("\t");
        }
        for(s=2*n-1;s>0;s--){
            printf(" 0\t");
        }
        printf("\n");
        
        
        for(space=n1-n;space>0;space--){
            printf("\t");
        }
        for(s=2*n-1;s>0;s--){
            printf("<H>\t");
        }
        printf("\n");
        
        
        for(space=n1-n;space>0;space--){
            printf("\t");
        }
        
        for(s=2*n-1;s>0;s--){
            printf("I I\t");
        }
        for(space=n1-n;space>0;space--){
            printf("\t");
        }
        printf("\n");
    }
    return 0;
}

 

标签:main,space,int,--,实验,printf,include
From: https://www.cnblogs.com/u329089/p/17810648.html

相关文章

  • 实验三
    1.test11#include<stdlib.h>2#include<time.h>3#include<windows.h>4#defineN805#include<stdio.h>67voidprint_text(intline,intcol,chartext[]);8voidprint_spaces(intn);9voidprint_blank_lines(intn);......
  • 实验3
    任务1代码1#include<stdio.h>2#include<stdlib.h>3#include<time.h>4#include<windows.h>5#defineN806voidprint_text(intline,intcol,chartext[]);7voidprint_spaces(intn);8voidprint_blank_lines(intn);......
  • 实验3 C语言函数应用编程
    一、实验目的二、实验准备三、实验内容1.实验任务1源代码:1#include<stdio.h>2#include<stdlib.h>3#include<time.h>4#include<windows.h>5#defineN8067voidprint_text(intline,intcol,chartext[]);//函数声明8voidprint_spaces(in......
  • 实验3
    #include<stdio.h>#include<stdlib.h>#include<time.h>#include<windows.h>#defineN80voidprint_text(intline,intcol,chartext[]);//函数声明voidprint_spaces(intn);//函数声明voidprint_blank_lines(intn);//函数声明int......
  • 实验3 C语言函数应用编程
    实验任务1:#include<stdio.h>#include<stdlib.h>#include<time.h>#include<windows.h>#defineN80voidprint_text(intline,intcol,chartext[]);voidprint_spaces(intn);voidprint_blank_lines(intn);intmain(){intline,col,......
  • 实验3 C语言函数应用编程
    1、实验1实验1运行结果  实现了每隔一秒随机弹出“hi,November~”。2、实验2实验2-1源代码1#include<stdio.h>2longlongfac(intn);34intmain()5{6inti,n;78printf("Entern:");9scanf("%d",&n);1011for......
  • 实验三
    task1.c源代码1#include<stdio.h>2#include<stdlib.h>3#include<time.h>4#include<windows.h>5#defineN806voidprint_text(intline,intcol,chartext[]);//函数声明7voidprint_spaces(intn);//函数声明8voidprint_bl......
  • 实验3 类与数组、指针
    实验任务1point.hpp#pragmaonce#include<iostream>usingstd::cout;usingstd::endl;classPoint{public:Point(intx0=0,inty0=0);~Point()=default;intget_x()const;intget_y()const;voidshow()const;voidmo......
  • 实验三-类与数组、指针
    point.hpp1#pragmaonce23#include<iostream>4usingstd::cout;5usingstd::endl;67classPoint{8public:9Point(intx0=0,inty0=0);10~Point()=default;1112intget_x()const;13intget_y()const;1......
  • 实验2 类和对象_基础编程2
    实验任务1demo1.dev方法一#ifndefT_H#defineT_H#include<iostream>#include<string>usingnamespacestd;//类T的声明classT{public:T(intx=0,inty=0);//带有默认形值的构造函数T(constT&t);//复制构造函数T(T&&......