自由尋覓快樂別人從沒法感受

0%

题目:输入一个百分制成绩,按要求输出对应的成绩等级。

90分以上为A(包括90)
80-90分为B(包括80)
70-80分为C(包括70)
60-70分为D(包括60)
60一下为E

主要代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# include <stdio.h>
void judge (float a);
int main ()
{
float score;
printf("input stduent's score(0-100):");
scanf("%f",&score);
if (score<0 || score>100)
{
printf("score input illegal!");
}
else
{
printf("student's score is:%.1f \n",score);
judge(score);
}
return 0;
}

void judge (float a)
{
char jlevel;
if (a>=90)
{
printf("student's level is:A\n");
}
else if (a<90 && a>=80)
{
printf("student's level is:B\n");
}
else if (a<80 && a>=70)
{
printf("student's level is:C\n");
}
else if (a<70 && a>=60)
{
printf("student's level is:D\n");
}
else
{
printf("student's level is:E\n");
}
}
阅读全文 »

题目:输入三个数,判断这三个数对应长度的线段构成的三角形是什么类型。设计数据并测试程序。

主要代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# include <stdio.h>
int maxiumn (int x,int y,int z);
int main (void)
{
int a,b,c;
printf("triangle's a line:");
scanf("%d",&a);
printf("triangle's b line:");
scanf("%d",&b);
printf("triangle's c line:");
scanf("%d",&c);
//input tri's 3 line
if (a<0 || b<0 || c<0)
{
printf("error!It's not a triangle!");
}
else
{
if (a+b<c || a+c<b || b+c<a) //judge if it's tri or not
{
printf("error! \n");
}
else
{
int mac,l1,l2;
mac=maxiumn(a,b,c);
if (mac==a) //judge the line from big to small
{
l1=b;
l2=c;
}
else if (mac==b)
{
l1=a;
l2=c;
}
else
{
l1=a;
l2=b;
}
if (l1*l1+l2*l2==mac*mac) //judge the shape of triangle
{
printf("it's a RT triangle \n");
}
else if (l1*l1+l2*l2<mac*mac)
{
printf("it's a acute angle triangle\n");
}
else
{
printf("it's an obtuse angle triangle\n");
}
}
}
return 0;
}

int maxiumn (int x,int y,int z) //count the longest line
{
int max;
if (x>y)
{
max=x;
}
else
{
max=y;
}
if (max<z)
{
max=z;
}
printf("the max line:%d \n",max);
return max;
}
阅读全文 »

题目:设w是一个大于10的无符号整数,若w是n(n>=2)位的整数,编写一个函数求w的低n-1位的数作为函数的返回值。

如w=5923,则函数返回值为923。

主要代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# include <stdio.h>
int fan(int x);
int main ()
{
unsigned int w,y;
printf("input number:");
scanf("%d",&w);
y=fan(w);
printf("output:%d\n",y);
return 0;
}

int fan(int x)
{
int z=0,y=0;
while(x/10 != 0)
{
z=z*10+x%10;
x=x/10;
}
while (z != 0)
{
y=y*10+z%10;
z=z/10;
}
return y;
}
阅读全文 »

题目:使用函数调用的方法计算下面式子的值

y = (2n-1)/(2n)/(2*n) (其中n等于1)

主要代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# include <stdio.h>
# include <math.h>
float function (float n);
int main (void)
{
float y;
y = function(1);
printf("y=%f\n",y);
return 0;
}

float function (float n)
{
float a,y=0;
for (n=1;;n++)
{
a = (2*n-1)/(2*n)/(2*n);
if(a>0.0001)
{
y = y + a;
}
else
{
break;
}
}
return y;
}
阅读全文 »

题目:计算银行存款余额和利息

假设银行存款季度利息是5.3%。
根据输入的原始数据计算利息和账户余额,并以表格的形式输出每个季度的利息和账户余额。
要求写两个函数,一个用来计算利息和余额,一个用来输出。

主要代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# include <stdio.h>
# include <math.h>
float function (float sum);
float finals (float a);
int main (void)
{
printf("seasonal lixi is>>>>>>>5.3%\n");
float a,z;
printf("input start money:");
scanf("%f",&a);
z = finals(a);
return 0;
}

float function (float sum)
{
float lixi;
lixi = sum*0.053;
sum = sum + lixi;
return sum;
}

float finals (float a)
{
float x,y,z; //x为利息,y为总金
int b,i=0,c=0;
z = function(a);
while (z/10 > 1)
{
i = i + 1;
z = z/10;
}
printf("---date---");
for (c=0;c<=i;c++)
{
printf("-");
}
printf("-------money--------------lixi----------- \n");
for (b=1;b<=4;b++)
{
y = function(a);
x = y - a;
printf("|the %d season: %.2f %.2f | \n",b,y,x);
a = y;
}
for (c=0;c<=i;c++)
{
printf("-");
}
printf("--------------------------------------------------- \n");
return 0;
}
阅读全文 »