首页 > 其他分享 >实验2

实验2

时间:2023-03-17 22:22:47浏览次数:29  
标签:include int scanf printf 实验 ans main




#include <stdio.h>//task2.1
#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;
    
 } 

随机生成r1到r2内的整数 生成202283300586到202283300701内整数

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

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

scanf(" %lf %lf", &x, &y);
printf("x = %f, y = %f",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 x, ans;

 


{
ans = x*9/5+32;
printf("摄氏度c=%.2f时,华氏度f= %.2f\n", x, ans);
printf("\n");
} return 0;
}

#include <stdio.h>
#include<Windows.h>
#include<math.h>
int main()
{
   char m;
    while(scanf(" %c", &m) != EOF){
    
    switch(m){
        case 'r': printf("stop!\n");break;
        case 'g': printf("go go go!\n");break;
        case 'y': printf("wait a minute\n");break;
        default : printf("something must be wrong\n");break;                              
        
    system("pause");
    return 0;
}
    }
}

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

#define R1 30
#define R2 1

int main()
{
 int number;
 int i;
 int j;
 
 srand( time(0) ); // 以当前系统时间作为随机种子
 number=rand()%(R2-R1+1)+R2;
 
 for (i=1;i<=3;i++){
     scanf("%d",&j);
 if (j>number)
     printf("after\n");
 else if (j<number)
     printf("before\n");
 else 
     break;
 }
 printf("it is %d\n",number);
 system("pause");
 return 0;
} 

什么人品大爆发:)

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


int main()
{
 int n;
 int i;
 int j;
 
 for (i=1;i<=9;i++){
     for (j=1;j<=i;j++){
         n=i*j;
         printf("%d*%d = %2d  ",i,j,n);
     }
     printf("\n");
 }


 system("pause");
 return 0;
} 

 

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


int main()
{
 int n;
 int i;
 int j;
    scanf("%d",&i);
    n=i;
 
 for (;i>=1;i--){
     for (j=1;j<n-i+1;j++){
    printf("      ");}

     for (j=1;j<=i*2-1;j++){
    printf("  O   ");}
     printf("\n");

     for (j=1;j<n-i+1;j++){
    printf("      ");}

    for (j=1;j<=i*2-1;j++){        
    printf(" <H>  ");}
     printf("\n");

     for (j=1;j<n-i+1;j++){
    printf("      ");}

     for (j=1;j<=i*2-1;j++){        
    printf(" I I  ");}
     printf("\n");
     }
     
 


 system("pause");
 return 0;
} 

 

标签:include,int,scanf,printf,实验,ans,main
From: https://www.cnblogs.com/wu-wu-/p/17223597.html

相关文章

  • 实验2 C语言输入输出和控制语句应用编程
    一.实验结论1.实验任务1#include<stdio.h>#include<stdlib.h>#include<time.h>#defineN5#defineR1586#defineR2701intmain(){intnumber;......
  • 保龄球比赛计分程序实验报告
    1.试验目的写一个保龄球比赛计分程序。2.实验过程在写这个程序的过程中,我们犯了很多的错误。这些错误包括代码方面的、逻辑方面的、设计方面的以及需求方面的。在写这个......
  • 实验2
    实验任务1实验代码#include<stdio.h>#include<stdlib.h>#include<time.h>#defineN5#defineR1586#defineR2701intmain(){ intnumber; inti; sra......
  • 实验2
    实验任务1程序代码:#include<stdio.h>#include<stdlib.h>#include<time.h>#defineN5#defineR1586#defineR2701intmain(){intnumber;inti;......
  • 实验2
    实验二任务1:代码#include<stdio.h>#include<stdlib.h>#include<time.h>#defineN5#defineR1586#defineR2701intmain(){intnumber,i;......
  • 实验2
    实验2task1.实验代码#include<stdio.h>#include<stdlib.h>#include<time.h>#defineN5#defineR1586#defineR2701intmain(){ intnumber; inti; sra......
  • 实验2
    实验任务一代码1#include<stdio.h>2#include<stdlib.h>3#include<time.h>4#defineN55#defineR15866#defineR27017intmain()8{9......
  • 实验2
    #include<stdio.h>#include<stdlib.h>#include<time.h>#defineN5#defineR1586#defineR2701intmain(){intnumber;inti;srand(time......
  • 实验二
    task1#include<stdio.h>#include<stdlib.h>#include<time.h>#defineN5#defineR1586#defineR2701intmain(){intnumber;inti;......
  • 实验2
    实验任务1:#include<stdio.h>#include<stdlib.h>#include<time.h>#defineN5#defineR1586#defineR2701intmain(){intnumber;inti;srand(......