# 二．源程序

#### 4-6

#include<stdio.h>
int main()
{
int low, up;
scanf("%d %d", &low, &up);
double c=0;
if (low <= up&&up<=100&&low<=100) {
for (printf("fahr celsius\n"); low <= up; low += 2) {
c = 5.0 * (low - 32) / 9.0;
printf("%d%6.1lf\n", low, c);
}
}
else {
printf("Invalid.");
}
return 0;
}

#### 4-5

#include <stdio.h>
#include <math.h>
int main()
{
double n, s ,i,m,a;
s = 0;
i = 1;
m = 1;
a = 2;
scanf("%lf", &n);
while (m <= n) {
s = 1 / i * pow(-1,a)+ s;
i = i + 3;
m++;
a++;
}
printf("sum = %.3f", s);
return 0;
}

#### 4-2-6

#include <stdio.h>
#include <math.h>
int main()
{
int a, d,i,c;
int b, e;
double n;
scanf("%d", &a);
int h[21];int w[21];
for (b = 0; b < a; b++) {
scanf("%d %d", &c, &d);
h[b] = c; w[b] = d;
}
for (e = 0; e < a; e++) {
n = (h[e] - 100)*0.9 * 2;
if (fabs(w[e] - n) < n*0.1) {
printf("You are wan mei!\n");
}
else if (fabs(w[e] - n) >= n*0.1 && w[e] > n) {
printf("You are tai pang le!\n");
}
else if (fabs(w[e] - n) >= n*0.1 && w[e] < n) {
printf("You are tai shou le!\n");
}
}
return 0;
}

# 三．遇到的问题及解决方法，心得体会

1.对输出格式的重要，比如题目要求输出占据6个字符宽度的数据，而我多次没注意（还有先前实验中对空格的要求）2.在一些数学运算中多次没有在开头输入math.h头文件进行声明3.对数组的定义不够熟练，对[]内的数值没有明确概念和各个数值对应的数组值。最后经过百度和c语言书籍进行解决

posted @ 2017-10-21 00:13  吴修恩  阅读(1009)  评论(0编辑  收藏  举报