首页 > 其他分享 >实验2

实验2

时间:2023-03-17 23:24:20浏览次数:37  
标签:include int scanf pause 实验 printf main

 

 任务一 

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

int main()
{
	double x,ans;
	while(scanf("%if",&x)!=EOF)
	{
	
	    printf("202283300%04d\n",number);
	}
	system("pause");
	return 0;
}

  

 line 18 生产一个586到701的随机数

任务二

#include <stdio.h>
#include <stdlib.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=%lf,y=%lf\n",x,y);
	
	system("pause");
	return 0;
}

  

 

  任务三

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


int main()
{
	double x,ans;
    while(scanf("%lf",&x)!=EOF)
	{
	ans=pow(x,365);

	printf("%.2f的365次方%.2f\n",x,ans);
	
	}
	system("pause");
	return 0;
}

  

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


int main()
{
	double c,f;
    while(scanf("%lf",&c)!=EOF)
	{
	f=32+c*9/5;

	printf("摄氏度%.2f时,华氏度为%.2f\n",c,f);
	printf("\n");
	}
	system("pause");
	return 0;
}

  

任务四

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


int main()
{
	char g,r,y,yanse;
	while(scanf("%c",&yanse)!=EOF)
	{
	   getchar();
		switch(yanse)
	    {
	    case('r') :printf("stop!\n");break;
	    case('g') :printf("go go go\n");break;
	    case('y') :printf("wait\n");break;
	    default :printf("something is wrong\n");
		
	     }
	}
	system("pause");
	return 0;
}

  

任务五

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

int main()
{
	
	int shu,i,n;
	i=1;
	srand(time(0));
		 shu=rand()%30+1;
	 printf("请猜数:\n");
	 while(i<4){
		 scanf("%d",&n);

		 if(n>shu){
			 i++;
			 printf("猜大啦\n");
		 }
	     else if(n<shu){
			 i++;
			 printf("猜小啦\n");}
	     else if(n=shu){
			 i++;
			 printf("猜对啦\n");
		 }    
		
	 }
	 if (i == 3)
	 printf("你的幸运数字是%d",shu);
	system("pause");
	return 0;
}

  

 

 

任务六

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

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

  

 任务七

#include <stdio.h>
#include <stdlib.h>
int main()
{
	int i, j, n, k,l,m,o,p;

	scanf("%d", &n);
	for (i = 1; i <= n; i++)    //i小于行数就打//
	{
		for (j = 0; j < i; j++)  //j小于i就打空行//
		{
			printf("\t");
		}
		for (k = i; k < 2 * n - 1 - i; k++)  //让k等于i,每一行k也加,k小于2行数减一时候就打一个头,一开始i=1,n=5,打印0,第一次打了7个//
		{
			printf(" 0\t");
		}
		printf("\n");
		for ( l= 0; l< i; l++)//dayinkongge
		{
			printf("\t");
		}
		for (m = i; m < 2 * n - 1 - i;m++)  
		{
			printf("<H>\t");
		}
		printf("\n");
		for (o = 0; o< i; o++)
		{
			printf("\t");
		}
		for (p= i; p < 2 * n - 1 - i;p++)
		{
			printf("I I\t");
		}
		printf("\n\n");

	}
	system("pause");
	return 0;
}

  

 

标签:include,int,scanf,pause,实验,printf,main
From: https://www.cnblogs.com/jiang4533/p/17223913.html

相关文章

  • 实验2 c语言输入输出和控制语句应用编程
    TEST 1源代码:#include<stdlib.h>#include<stdio.h>#include<time.h>#defineN5#defineR1586#defineR2701intmain(){  intnumber;  inti;  sran......
  • 实验2
    #include<stdio.h>//task2.1#include<stdlib.h>#include<time.h>#defineN5#defineR1586#defineR2701intmain(){intnumber;inti;s......
  • 实验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......