首页 > 其他分享 >实验1

实验1

时间:2024-10-01 21:48:53浏览次数:10  
标签:lf main return int 实验 printf include

task1

点击查看代码
#include <stdio.h>
int main()
{
	int i;
	for (i = 0 ; i < 2 ; i++)
	{
		printf(" o  \n");
		printf("<H> \n");
		printf("I I \n");
	}
	return 0;
}

点击查看代码
#include <stdio.h>
int main()
{
	

		printf(" o    o \n");
		printf("<H>  <H>\n");
		printf("I I  I I\n");

	return 0;
}
![](https
![](http://img2024.cnblogs.com/blog/3527145/202410/3527145-20241001212052302-528216347.png)

========================================================================================================================================================
task2

点击查看代码
#include <stdio.h>
int main()
{
	double a, b, c;

	scanf("%lf%lf%lf", &a, &b, &c);

	if(a + b > c)
		printf("能构成三角形\n");
	else
		printf("不能构成三角形\n");
	return 0;
}
![](/i/l/?n=24&i=blog/3527145/202410/3527145-20241001212240932-403762718.png)

==============================================================================================================================================
task3

点击查看代码
#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罗马不是一天建成的, 继续保持哦:)\n");
	else
		printf("\n罗马不是一天毁灭的, 我们来建设吧\n");
		
	return 0;
}
![](/i/l/?n=24&i=blog/3527145/202410/3527145-20241001212431019-657798156.png) 把冒号拿掉 =============================================================================================================================================

task4

点击查看代码
#include<stdio.h>
int main()
{
 double x, y;
 char c1, c2, c3;
 int a1, a2, a3;
 
 scanf("%d%d%d",&a1,&a2,&a3);
 getchar();
 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);
 return 0;
}

================================================================================================================================
task5

点击查看代码
#include <stdio.h>
int main() 
{
int year;
double a=1.0e+009;
year = a/(365.0*86400.0)+0.5;
printf("10亿秒约等于%d年\n", year);
return 0;
}

===================================================================================================================================

task6

点击查看代码
#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;
}

task7

点击查看代码
#include <stdio.h>
int main()
{
 double c, f;
 
 while(scanf("%lf", &c) != EOF)
 {
	f=1.8*c+32;
	printf("摄氏度%.2lf时,华氏度为%.2lf\n",c,f);
 } 
 
 return 0;
}

=========================================================================================================================
task8

点击查看代码
#include <stdio.h>
#include <math.h>
int main()
{
 double a,b,c,s;
 
 while(scanf("%lf,%lf,%lf", &a,&b,&c) != EOF)
 {
	s=(a+b+c)/2;
	
	printf("面积为%.3lf\n",sqrt(s*(s-a)*(s-b)*(s-c)));
 } 
 
 return 0;
}

标签:lf,main,return,int,实验,printf,include
From: https://www.cnblogs.com/yzyzyz/p/18443356

相关文章

  • 实验1
    任务1:1#include<stdio.h>2intmain()3{4printf("O\n");5printf("<H>\n");6printf("II\n");7printf("O\n");8printf("<H>\n");9printf(&......
  • 实验一
    任务一源代码 #include<stdio.h>intmain(){printf("OO\n");printf("<H><H>\n");printf("IIII\n");return0;}  运行结果 源代码#include<stdio.h>#include<stdio.h>int......
  • 实验1
    实验1.1代码:1#include<stdio.h>2intmain()3{4printf("O\n");5printf("<H>\n");6printf("II\n");7return0;8}1.2:代码:1#include<stdio.h>2intmain()3{4printf("O\n&......
  • 实验1 C语言输入输出和简单程序编写
    1.实验任务1#include<stdio.h>intmain(){printf("oo\n");printf("<H><H>\n");printf("IIII\n");return0;} 2.实验任务2//从键盘上输入三个数据作为三角形边长,判断其能否构成三角形//构成三......
  • 实验1 C语言输入输出和简单程序编写
    1.实验任务1task1_1.c#include<stdio.h>intmain(){printf("o\n");printf("<H>\n");printf("II\n");printf("o\n");printf("<H>\n");printf("II\n&q......
  • 实验1
    任务一#include<stdio.h>intmain(){printf("O\n");printf("<H>\n");printf("II\n");return0;}intmain(){printf("O\n");printf("<H>\n");printf("II\n");prin......
  • 实验1
    任务一#include<stdio.h>intmain(){printf("O\n");printf("<H>\n");printf("II\n");printf("O\n");printf("<H>\n");printf("II\n");return......
  • 实验1
    任务1:源代码1#include<stdio.h>2intmain()3{4printf("O\n");5printf("<H>\n");6printf("II\n");7printf("O\n");8printf("<H>\n");9prin......
  • 实验1 C语言输入输出和简单程序编写
    一,实验目的1.会使用C语言程序开发环境(vs2010/devc++等),能熟练、正确使用它们编写、编译、运行、调试C程序2.知道C程序结构和编码规范,能正确使用3.能正确、熟练使用C语言输入输出函数:scanf(),printf(),getchar(),putchar()4.能灵活、组合使用基本数据类型、运算符和......
  • 实验1
    task1#include<stdio.h>intmain(){printf("O\n");printf("<H>\n");printf("II\n");return0;}    图片      task2#include<stdio.h>intmain(){doublea,b,c;......