实验二

#include<stdio.h>
int main()
{
int num;
 while(scanf("%d",&num)!= 0)
 {
 printf("2049%04d\n",num);    
 }
return 0;
} 

 

#include<stdio.h>
int main()
{
int num;
 scanf("%d",&num); 
 printf("2049%04d\n",num);    
  scanf("%d",&num); 
 printf("2049%04d\n",num);    
  scanf("%d",&num); 
 printf("2049%04d\n",num);    
return 0;
} 

 

#include<stdio.h>
int main()
{
  char ans1,ans2;
  printf("复习了没?(输入y或Y表示复习了,输入n或N表示没复习:");    
  ans1=getchar();
  getchar();
  printf("\n动手敲代码了没?(输入y或Y表示敲了,输入n或N表示没的敲:");
  ans2=getchar();
  if((ans1=='y'||ans1=='Y')&&(ans2=='y'||ans2=='Y'))
  printf("\n罗马不是一天建成的:"); 
  else
  printf("罗马不是一天毁灭的:");
  return 0;
}

 

#include<stdio.h>
int main()
{
    char x;
    x=getchar();
    if(x>='0'&&x<='9')
    printf("%c是数字字符\n",x);
    else if(x>='a'&&x<='z'||x>='A'&&x<='Z')
    printf("%c是英文字符\n",x);
    else
    printf("%c是其它字符",x);
    return 0;
}

 

 

#include<stdio.h>
#include<stdlib.h>
#include<time.h>
const int N = 5;
int main()
{
int x, n;
srand(time(0));
for (n = 1; n <= N; n++)
{
x = rand() % 100; 
printf("%3d", x);
}
printf("\n");
return 0;
}

 

#include<stdio.h>
int main()
{
 int n,i=1; 
 scanf("%d",&n);
 while(i<=n)
 {
   printf(" O\n");
  printf("<H>\n");
   printf("I I\n");
  i++;
 }
 return 0;
} 

 

 

posted @ 2021-11-16 23:53  谷子航  阅读(15)  评论(3编辑  收藏  举报