首页 > 其他分享 >实验

实验

时间:2024-09-28 21:24:27浏览次数:1  
标签:include return 源代码 int 实验 printf main

试验任务一:

源代码(竖直方向):

 1 #include<stdio.h> 
 2 int main()
 3 {
 4     printf(" o \n");
 5     printf("<H>\n");
 6     printf("I I\n");
 7     printf(" o \n");
 8     printf("<H>\n");
 9     printf("I I\n");
10     return 0;
11     
12 }
View Code

运行结果:

 

 

 

源代码(水平方向):

1 #include<stdio.h> 
2 int main()
3 {
4     printf(" o \t o \n");
5     printf("<H>\t<H>\n");
6     printf("I I\tI I\n");
7     return 0;
8     
9 }
View Code 运行结果:

实验任务2:

源代码:

 1 #include<stdio.h> 
 2 int main()
 3 {
 4     double a,b,c;
 5     scanf("%lf%lf%lf",&a,&b,&c);
 6     if(a+b>c&&a+c>b&&b+c>a)
 7         printf("能构成三角函数\n");
 8     else
 9         printf("不能构成三角形\n");
10         
11     return 0;  
12 }
View Code

运行结果:

实验任务3:

 源代码:

 1 #include <stdio.h>
 2  int main()
 3  {
 4     char ans1, ans2; 
 5     printf("每次课前认真预习、课后及时复习了没? (输入y或Y表示有,输入n或N表示没有) : ");
 6     ans1 = getchar();
 7     getchar();
 8     printf("动手敲代码实践了没? (输入y或Y表示敲了,输入n或N表示没有敲) : ");
 9     ans2 = getchar();
10     if ((ans1=='Y'||ans1=='y')&&(ans2=='Y'||ans2=='y')) 
11         printf("\n罗马不是一天建成的, 继续保持哦:)\n");
12     else
13         printf("\n罗马不是一天毁灭的, 我们来建设吧\n");
14     return 0;
15 }
View Code

运行结果:

结果分析:

进入缓存区,无法拿走数据

实验任务4:

源代码:

 1 #include<stdio.h>
 2 int main()
 3 {
 4 double x, y;
 5 char c1, c2, c3;
 6 int a1, a2, a3;
 7 scanf("%d%d%d",&a1, &a2, &a3);//a1,a2,a3前未加& 
 8 printf("a1 = %d, a2 = %d, a3 = %d\n", a1,a2,a3);
 9 scanf("%c%c%c", &c1, &c2, &c3);
10 printf("c1 = %c, c2 = %c, c3 = %c\n", c1, c2, c3);
11 scanf("%lf%lf",&x,&y);//double为%lf而不是%f 
12 printf("x = %lf, y = %lf\n",x, y);
13 return 0;
14 }
View Code

运行结果:

 

 实验任务5:

源代码:

 1 #include <stdio.h>
 2 int main()
 3 {
 4 int year;
 5 int second;
 6 scanf("%d",&second) ;
 7 year=second/60/60/24/365;
 8 printf("10亿秒约等于%d年\n", year);
 9 return 0;
10 }
View Code

运行结果:

实验任务6:

源代码:

 1 #include <stdio.h>
 2 #include <math.h>
 3 int main()
 4 {
 5 double x, ans;
 6 while(scanf("%lf", &x) != EOF)
 7 {
 8 ans = pow(x, 365);
 9 printf("%.2f的365次方: %.2f\n", x, ans);
10 printf("\n");
11 }
12 return 0;
13 }
View Code

运行结果:

实验任务7:

源代码:

 1 #include <stdio.h>
 2 
 3 int main() 
 4 {
 5     double f, c;
 6    
 7     while (scanf("%lf", &c)!= EOF)
 8      {
 9         f = 1.8 * c+ 32;
10         printf("摄氏度 c=%.2lf,华氏度 f=%.2lf\n", c, f);
11         
12     }
13     return 0;
14 }
View Code

运行结果:

实验任务8:

源代码:

 1 #include<stdio.h>
 2 #include<math.h>
 3 int main() 
 4 {
 5     int a,b,c;
 6     double s,area;
 7     while(scanf("%d%d%d",&a,&b,&c)!=EOF)
 8     { 
 9     s=(a+b+c)/2.0;
10     area=sqrt(s*(s-a)*(s-b)*(s-c));  
11     printf("a=%d,b=%d,c=%d,area=%.3lf\n",a,b,c,area);
12     printf("\n");
13     }
14     return 0;
15 }
View Code

运行结果:

 

标签:include,return,源代码,int,实验,printf,main
From: https://www.cnblogs.com/noeleven/p/18431782

相关文章

  • 实验1
        任务1源代码(1)1#include<stdio.h>2intmain(){3printf("0\n");4printf("<H>\n");5printf("II\n");6return0;7}  源代码(2)1#include<stdio.h>2intmain(){3......
  • 实验1
    任务1#include<stdio.h>intmain(){printf("o\to\n");printf("<H>\t<H>\n");printf("II\tII\n");return0;}#include<stdio.h>intmain(){printf("o......
  • 实验1
    任务1:水平方向#include<stdio.h>intmain(){printf("O  O\n");printf("<H><H>\n");printf("IIII\n");return0;}竖直方向#include<stdio.h>intmain(){printf("O\n");printf("&......
  • 《DNK210使用指南 -CanMV版 V1.0》第二十七章 摄像头图像调整实验
    第二十七章摄像头图像调整实验1)实验平台:正点原子DNK210开发板2)章节摘自【正点原子】DNK210使用指南-CanMV版V1.03)购买链接:https://detail.tmall.com/item.htm?&id=7828013987504)全套实验源码+手册+视频下载地址:http://www.openedv.com/docs/boards/k210/ATK-DNK210.html5......
  • 实验1
    task1.1c1#include<stdio.h>2intmain()3{4printf("O\n");5printf("<H>\n");6printf("II\n");7printf("O\n");8printf("<H>\n");9printf(......
  • java计算机毕业设计的实验室仪器管理(开题+程序+论文)
    本系统(程序+源码)带文档lw万字以上 文末可获取一份本项目的java源码和数据库参考。系统程序文件列表开题报告内容研究背景随着科技的飞速发展,实验室作为科学研究和技术创新的核心场所,其管理效率与信息化水平直接影响到科研活动的顺利进行与成果产出。传统的手工管理模式在......
  • 实验1 c语言输入输出和简单程序编写
    任务1:task1.11#include<stdio.h>2345intmain()6{7printf("o\n");8printf("<H>\n");9printf("II\n");10printf("o\n"......
  • 动手动脑动手实验
    (1)枚举类型是引用类型!枚举不属于原始数据类型,它的每个具体值都引用一个特定的对象。相同的值则引用同一个对象。可以使用“”和equals()方法直接比对枚举变量的值,换句话说,对于枚举类型的变量,“”和equals()方法执行的结果是等价的。(2)(3)(4)在Java中,变量的“同名变量的屏......
  • 实验一
    任务1_11#include<stdio.h>2intmain()3{4printf("O\n");5printf("<H>\n");6printf("II\n");7printf("O\n");8printf("<H>\n");9printf("......
  • 实验1
    实验任务1:源代码task1_1.c:1#include<stdio.h>2intmain()3{4printf("o\n");5printf("<H>\n");6printf("II\n");7printf("o\n");8printf("<H>\n");......