实验2


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

 

posted @ 2023-03-17 22:18  无舞物  阅读(14)  评论(0编辑  收藏  举报