实验1 C语言开发环境使用和数据类型、运算符、表达式

news/发布时间2024/4/30 4:56:20

task1

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

点击查看代码
#include <stdio.h>int main()
{printf(" o\t");printf(" o\n");printf("<H>\t");printf("<H>\n");printf("I I\t");printf("I I\n");system("pause");return 0;
}

task2

点击查看代码
#include<stdio.h>
#include<stdlib.h>int main()
{float a,b,c;scanf("%f%f%f",&a,&b,&c);if(a+b>c&&a+c>b&&b+c>a)printf("能构成三角形\n");elseprintf("不能构成三角形\n");system("pause");return 0;
}



task3

点击查看代码
#include<stdio.h>
#include<stdlib.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");elseprintf("\n罗马不是一天毁灭的,我们来建设吧\n");system("pause");return 0;
}





去掉后程序在输入第二个回答后自动关闭
因为在回答时输入了“答案”“回车”“答案”,getchar()是为了抵消中间回车对第二个答案的影响。

task4

点击查看代码
#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);   //%f,%lf",&x,&y改为%lf,%lf",&x,&yprintf("x=%f,y=%lf\n",x,y);system("pause");return 0;
}

task5

点击查看代码
#include<stdio.h>
#include<stdlib.h>int main()
{int year;year=1000000000;year=(year+0.5)/3600/24/365;printf("十亿秒约等于%d年\n",year);system("pause");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>
#include<math.h>int main()
{double c,f;while(scanf("%lf",&c)!=EOF){f=(9*c)/5+32;printf("摄氏度c=%.2f时,华氏度f=%.2f\n",c,f);printf("\n");}system("pause");return 0;
}

task8

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

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.ulsteruni.cn/article/65130802.html

如若内容造成侵权/违法违规/事实不符,请联系编程大学网进行投诉反馈email:xxxxxxxx@qq.com,一经查实,立即删除!

相关文章

Packet for query is too large解决方案

华为云开发者联盟 Packet for query is too large (5,196,813 > 4,194,304). You can change this value on the server by se Packet for query is too large (5,196,813 > 4,194,304). You can change this value on the server by se 处理办法:1. 先查询,会看见一个现…

LeetCode[题解] 1261. 在受污染的二叉树中查找元素

首先我们看原题 给出一个满足下述规则的二叉树:root.val == 0 如果 treeNode.val == x 且 treeNode.left != null,那么 treeNode.left.val == 2 * x + 1 如果 treeNode.val == x 且 treeNode.right != null,那么 treeNode.right.val == 2 * x + 2现在这个二叉树受到「污染」…

【PR】UC-NERF: NEURAL RADIANCE FIELD FOR UNDERCALIBRATED MULTI-VIEW CAMERAS IN AUTONOMOUS DRIVING

【简介】 这篇文章的作者来自中科大、北大武汉人工智能研究院、大疆和上海科大,投稿到了ICLR 2024会议,已接收。 UC,表示under calibrated,意味着标定不准。本文提出UC-NeRF用于解决标定不够好的多相机配置的新视角合成方法。首先,作者提出一种基于层的颜色校正方法,以纠…

安装部署gitea

gitea介绍 官网 https://about.gitea.cn/ 最近发现gitea的官网发生了变化,也不知道什么时候改了,之前的域名是gitea.io的,但是现在会跳转到about.gitea.cn域名上可能是商业化了吧,但这也并不意味着 Gitea 就变成了商业软件。 Gitea 目前仍然是一个完全免费且开源的项目,任…

Vulnhub之DarkHole_1

DarkHole_1一 信息收集IP扫描端口扫描访问80目录扫描查看目录80网页 -->login 注册用户我的 id 是 2,那么应该有个账号是 id=1,尝试越权修改 id=1 的密码把id改为1发现登陆成功,多了一个上传文件的地方,前面的目录扫描中我们也发现了 /upload 路径,尝试上传反弹 sh…

R:共现网络图例绘制

# 清除所有变量 rm(list = ls()) # 设置工作目录 setwd("C:\\Users\\Administrator\\Desktop\\新建文件夹\\Co-occurrence Network\\图例") # 载入ggplot2包 library(ggplot2)# 创建一个数据框,包含您想要在图例中展示的颜色和类别 # 确保Category是按照正确的顺序设…