首页 > 其他分享 >实验二

实验二

时间:2023-03-22 22:25:17浏览次数:32  
标签:lf include int scanf 实验 printf 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;
}

问题一:生成586-701之间的随机数

问题二:一次性随机生成五个202283300。。。后面三个数字为586-701之间的随机数

#include<stdio.h>

int main()
{
    double x,y;
    char c1,c2,c3;
    int a1,a2,a3;
    scanf("%d%d%d",&a1,&a2,&a3);
    printf("a1=%d,a2=%d,a3=%d\n",a1,a2,a3);
    getchar();
    scanf("%c%c%c",&c1,&c2,&c3);
    printf("c1=%c,c2=%c,c3=%c\n",c1,c2,c3);
    getchar();
    scanf("%lf,%lf\n",x,y);
    printf("x=%lf,y=%lf\n",x,y);
    
    system("pause");
    
    return 0;
}
数字和数字之间需要空格,字母和小数不需要
#include <stdio.h>
#include<math.h>
#include<stdlib.h>
int main ()
{
    double x,ans;
    scanf("%lf",&x);
    ans=pow(x,365);
    printf("%.2f的365次方:%.2f\n",x,ans);
 
 
 
    system("pause");
    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 = %.2lf时,华氏度F = %.2lf",c,F);
        printf("\n");
    }
    return 0;

#include <stdio.h>

int main()
{
    char c;
    while(scanf("%c", &c) != EOF)
    
{   switch(c){

    case'y':printf("wait a minute\n");break;
    case'g':printf("go go go");break;
    case'r':printf("stop!");break;
    case'x':printf("something must be wrong");}
   
   
}getchar();
      return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
    int x,n,i;
    srand(time(0));
    x = rand() %(30)+1;
    printf("猜猜2023年4月哪一天会是你的lucky day\n开始喽,你有三次机会,");
    for(i=0;i<3;i++){
        printf("猜吧(1-30):");
        scanf("%d",&n);
        if(n==x)
            {printf("哇,你中了!!!\n");break;}
        else
            if(n<x)
                printf("你猜的时间早了哦\n");
            else
                printf("你猜的时间晚了哦\n");
            if(i==2)
                printf("次数用完啦,偷偷告诉你,4月你的lucky day是%d号\n",x);
        }
    system("pause");

    return 0;
}

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

int main() {
    int i, j;
    
    for(i = 1;i <= 9; i++) {
        for(j = 1;j <= i; j++) {
            printf("%d*%d =%3d ", j, i, j * i);
        } 
        printf("\n");
    }
    system("pause");
    return 0;
}

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

 

 

 



 



标签:lf,include,int,scanf,实验,printf,main
From: https://www.cnblogs.com/cybcyb/p/17223566.html

相关文章

  • 实验2 字符串和列表
    一、实验结论:1、实验任务1:task1.py程序源码:1#字符串的基础操作2#课堂上没有演示的一些方法34x='nbaFIFA'5print(x.upper())#字符串转......
  • 实验2 字符串和列表
    任务1x='nbaFIFA'print(x.upper())print(x.lower())print(x.swapcase())print()x='abc'print(x.center(10,'*'))print(x.ljust(10,'*'))print(x.rjust(10,'*'......
  • 实验2
    2.1#include<stdio.h>#include<stdlib.h>#include<time.h>#defineN6#defineR1586#defineR2701intmain(){intnumber;inti;srand(time(0));for(i=0;......
  • 实验2
    #include<stdio.h>#include<stdlib.h>#include<time.h>#defineN5#defineR1586#defineR2701intmain(){intnumber;inti;srand(ti......
  • 实验2
    实验任务1#include<stdio.h>#include<stdlib.h>#include<time.h>#defineN5#defineR1586#defineR2701intmain(){intnumber;inti;......
  • 实验2 字符串与列表
    1x='nbaFIFA'2print(x.upper())3print(x.lower())4print(x.swapcase())5print()67x='abc'8print(x.center(10,'*'))9print(x.ljust(10,'*'))......
  • 实验2
    x='nbaFIFA'print(x.upper())print(x.lower())print(x.swapcase())print()x='abc'print(x.center(10,'*'))print(x.ljust(10,'*'))print(x.rjust(10,'*'))......
  • 实验二
    task1#include<stdio.h>#include<stdlib.h>#include<time.h>#defineN5#defineR1586#defineR2701intmain(){intnumber;inti;sra......
  • 实验2
    实验任务1  问题一:line18将几个随机数组合起来问题二:根据当时的电脑时间,随机生成四个四位数 实验任务2 #include<stdio.h>#include<stdlib.h>intmain()......
  • 实验2
    TASK1//程序作用:随机生成五个学号#include<stdio.h>#include<stdlib.h>#include<time.h>#defineN5#defineR1586#defineR2701intmain(){intnu......