实验二 基本数据类型的输入输出(2学时)
This commit is contained in:
parent
ab7721dfd5
commit
eafc6cb80b
13
02/1/1.c
Normal file
13
02/1/1.c
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main(){
|
||||||
|
|
||||||
|
int celsius,fahr;
|
||||||
|
|
||||||
|
fahr=100;
|
||||||
|
|
||||||
|
celsius=5*(fahr-32)/9;
|
||||||
|
|
||||||
|
printf("fahr=%d,celsius=%d\n",fahr,celsius);
|
||||||
|
|
||||||
|
}
|
BIN
02/1/1.png
Normal file
BIN
02/1/1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.2 KiB |
36
02/1/README.md
Normal file
36
02/1/README.md
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
【问题描述】 改正下列程序中的错误, 程序功能:求华氏温度100oF对应的摄氏温度。计算公式如下,
|
||||||
|
|
||||||
|
![1](1.png)
|
||||||
|
|
||||||
|
其中c为摄氏温度,f为华氏温度。提交改错后的代码文件。
|
||||||
|
|
||||||
|
```c
|
||||||
|
#include <stdoi.h>
|
||||||
|
|
||||||
|
Void main(){
|
||||||
|
|
||||||
|
int celsius;fahr;
|
||||||
|
|
||||||
|
fahr=100;
|
||||||
|
|
||||||
|
celsius=5*(fahr-32)/9;
|
||||||
|
|
||||||
|
printf(“fahr=d,celsius=%d\n”,fahr,celsius);
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
【输入形式】无
|
||||||
|
【输出形式】fahr=100,celsius=37
|
||||||
|
|
||||||
|
# 运行结果
|
||||||
|
|
||||||
|
成功通过编译, 且无编译警告
|
||||||
|
|
||||||
|
共有测试数据:1
|
||||||
|
平均占用内存:1.902K
|
||||||
|
平均CPU时间:0.00607S
|
||||||
|
平均墙钟时间:0.00613S
|
||||||
|
|
||||||
|
测试数据 评判结果
|
||||||
|
测试数据1 完全正确
|
11
02/2/2.c
Normal file
11
02/2/2.c
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
/* xtao */
|
||||||
|
#include<stdio.h>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
int a,b;
|
||||||
|
scanf("%d %d",&a,&b);
|
||||||
|
printf("%d + %d = %d\n%d - %d = %d\n%d * %d = %d\n%d / %d = %d",a,b,a+b,a,b,a-b,a,b,a*b,a,b,a/b);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
BIN
02/2/2.png
Normal file
BIN
02/2/2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.7 KiB |
24
02/2/README.md
Normal file
24
02/2/README.md
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
【问题描述】计算2个正整数的和、差、积、商并输出。题目保证输入和输出全部在整型范围内。
|
||||||
|
|
||||||
|
【输入形式】输入在一行中给出2个正整数A和B。
|
||||||
|
|
||||||
|
【输出形式】在4行中按照格式“A 运算符 B = 结果”顺序输出和、差、积、商。
|
||||||
|
|
||||||
|
【样例输入】3 2
|
||||||
|
|
||||||
|
【样例输出】 ![2.png](2.png) 注意:符号两边有空格
|
||||||
|
|
||||||
|
【评分标准】结果完全正确得30分,共2个测试点。
|
||||||
|
|
||||||
|
# 运行结果
|
||||||
|
|
||||||
|
成功通过编译, 且无编译警告
|
||||||
|
|
||||||
|
共有测试数据:2
|
||||||
|
平均占用内存:1.949K
|
||||||
|
平均CPU时间:0.00511S
|
||||||
|
平均墙钟时间:0.00510S
|
||||||
|
|
||||||
|
测试数据 评判结果
|
||||||
|
测试数据1 完全正确
|
||||||
|
测试数据2 完全正确
|
13
02/3/3.c
Normal file
13
02/3/3.c
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#include<stdio.h>
|
||||||
|
#include<math.h>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
float a,b,c,area,s;
|
||||||
|
scanf("%f %f %f",&a,&b,&c);
|
||||||
|
s = (a + b + c) / 2;
|
||||||
|
area = sqrt(s * (s - a) * (s - b) * (s-c));
|
||||||
|
printf("area = %.2f",area);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
BIN
02/3/3.png
Normal file
BIN
02/3/3.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.2 KiB |
24
02/3/README.md
Normal file
24
02/3/README.md
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
【问题描述】输入三角形三边长a,b,c,计算三角形的面积,公式如下,
|
||||||
|
|
||||||
|
![3.png](3.png)
|
||||||
|
|
||||||
|
【输入形式】输入3边边长(小数,整数都行),用空格间隔
|
||||||
|
|
||||||
|
【输出形式】输出 area = 面积,面积小数点后保留2位
|
||||||
|
|
||||||
|
【样例输入】3 4 5
|
||||||
|
|
||||||
|
【样例输出】area = 6.00
|
||||||
|
|
||||||
|
# 运行结果
|
||||||
|
|
||||||
|
成功通过编译, 且无编译警告
|
||||||
|
|
||||||
|
共有测试数据:2
|
||||||
|
平均占用内存:1.996K
|
||||||
|
平均CPU时间:0.00577S
|
||||||
|
平均墙钟时间:0.00580S
|
||||||
|
|
||||||
|
测试数据 评判结果
|
||||||
|
测试数据1 完全正确
|
||||||
|
测试数据2 完全正确
|
11
02/4/4.c
Normal file
11
02/4/4.c
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#include<stdio.h>
|
||||||
|
#include<ctype.h>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
char a;
|
||||||
|
scanf("%c",&a);
|
||||||
|
if (a == toupper(a)) printf("%c", tolower(a));
|
||||||
|
else printf("%c", toupper(a));
|
||||||
|
return 0;
|
||||||
|
}
|
32
02/4/README.md
Normal file
32
02/4/README.md
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
【问题描述】
|
||||||
|
|
||||||
|
从键盘输入一字符,如为大写字母,则转成小写输出,如为小写字母,则转成大写输出,否则按原样输出。
|
||||||
|
|
||||||
|
【输入形式】
|
||||||
|
|
||||||
|
从键盘输入一字符。
|
||||||
|
|
||||||
|
【输出形式】
|
||||||
|
|
||||||
|
输出按要求处理后的字符。
|
||||||
|
|
||||||
|
【样例输入】
|
||||||
|
|
||||||
|
m
|
||||||
|
|
||||||
|
【样例输出】
|
||||||
|
|
||||||
|
M
|
||||||
|
|
||||||
|
# 运行结果
|
||||||
|
|
||||||
|
成功通过编译, 且无编译警告
|
||||||
|
|
||||||
|
共有测试数据:2
|
||||||
|
平均占用内存:1.930K
|
||||||
|
平均CPU时间:0.00572S
|
||||||
|
平均墙钟时间:0.00573S
|
||||||
|
|
||||||
|
测试数据 评判结果
|
||||||
|
测试数据1 完全正确
|
||||||
|
测试数据2 完全正确
|
25
02/README.md
Normal file
25
02/README.md
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
# 实验二 基本数据类型的输入输出(2学时)
|
||||||
|
|
||||||
|
> 作业时间: 2021-09-28 10:07:00 至 2021-10-09 23:55:00
|
||||||
|
|
||||||
|
# 实验目的
|
||||||
|
|
||||||
|
1. 掌握C语言基本数据类型的概念,理解数据类型与运算的关系。
|
||||||
|
2. 熟悉简单变量的定义和赋值方法。
|
||||||
|
3. 掌握C语言程序的输入与输出方法。
|
||||||
|
4. 掌握C语言程序的顺序结构。
|
||||||
|
|
||||||
|
# 实验器材
|
||||||
|
|
||||||
|
计算机硬件环境:`PIII 667以上计算机;软件环境:Dev C++, Visual C++。`
|
||||||
|
|
||||||
|
# 技能要点
|
||||||
|
|
||||||
|
1. 学习C语言运算符优先级和结合性的概念,掌握算术表达式的计算方法及表达式计算中的类型转换方法;
|
||||||
|
2. 数学表达式的程序表示方法;
|
||||||
|
3. printf与scanf的使用方法。
|
||||||
|
|
||||||
|
# 思考题
|
||||||
|
|
||||||
|
1. 常量和变量的区别是什么?
|
||||||
|
2. 顺序结构程序设计的流程是什么?
|
@ -6,9 +6,14 @@ A repo to record my study life.
|
|||||||
|
|
||||||
- [实验一 C程序实验环境(2学时)](https://github.com/xtaodada/C-study/tree/master/00)
|
- [实验一 C程序实验环境(2学时)](https://github.com/xtaodada/C-study/tree/master/00)
|
||||||
- [ex0.1 在屏幕上输出指定的带框文字](https://github.com/xtaodada/C-study/tree/master/00/1)
|
- [ex0.1 在屏幕上输出指定的带框文字](https://github.com/xtaodada/C-study/tree/master/00/1)
|
||||||
- [ex0.2 在屏幕上输出倒三角](https://github.com/xtaodada/C-study/tree/master/00/1)
|
- [ex0.2 在屏幕上输出倒三角](https://github.com/xtaodada/C-study/tree/master/00/2)
|
||||||
- [ex0.3 程序改错题:改正下列程序中的错误,在屏幕上显示短句"Welcome to you!"](https://github.com/xtaodada/C-study/tree/master/00/3)
|
- [ex0.3 程序改错题:改正下列程序中的错误,在屏幕上显示短句"Welcome to you!"](https://github.com/xtaodada/C-study/tree/master/00/3)
|
||||||
- [第一章 作业](https://github.com/xtaodada/C-study/tree/master/01)
|
- [第一章 作业](https://github.com/xtaodada/C-study/tree/master/01)
|
||||||
- [ex1.1 计算平均值](https://github.com/xtaodada/C-study/tree/master/01/1)
|
- [ex1.1 计算平均值](https://github.com/xtaodada/C-study/tree/master/01/1)
|
||||||
- [ex1.2 简单图案](https://github.com/xtaodada/C-study/tree/master/01/2)
|
- [ex1.2 简单图案](https://github.com/xtaodada/C-study/tree/master/01/2)
|
||||||
- [ex1.3 整数分节输出 - 简单版](https://github.com/xtaodada/C-study/tree/master/01/3)
|
- [ex1.3 整数分节输出 - 简单版](https://github.com/xtaodada/C-study/tree/master/01/3)
|
||||||
|
- [实验二 基本数据类型的输入输出(2学时)](https://github.com/xtaodada/C-study/tree/master/02)
|
||||||
|
- [ex2.1 程序改错](https://github.com/xtaodada/C-study/tree/master/02/1)
|
||||||
|
- [ex2.2 整数的四则运算](https://github.com/xtaodada/C-study/tree/master/02/2)
|
||||||
|
- [ex2.3 输入三角形三边长计算三角形的面积](https://github.com/xtaodada/C-study/tree/master/02/3)
|
||||||
|
- [ex2.4 字母的大小写转换](https://github.com/xtaodada/C-study/tree/master/02/4)
|
||||||
|
Loading…
Reference in New Issue
Block a user