Skip to content

Commit b5acba8

Browse files
committed
全部上传
0 parents  commit b5acba8

File tree

2,200 files changed

+196628
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,200 files changed

+196628
-0
lines changed

Debug/test01_1 V4.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/* test01_1.cpp */
2+
3+
# include <stdio.h>
4+
int main(void)
5+
{
6+
printf("Hello World! \n");
7+
8+
return 0;
9+
}

Debug/test01_2 V4.cpp

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/* test01_2.cpp */
2+
3+
# include <stdio.h>
4+
int main(void)
5+
{
6+
int n;
7+
int factorial(int n);
8+
9+
scanf("%d", &n);
10+
printf("%d\n", factorial(n));
11+
12+
return 0;
13+
}
14+
15+
int factorial(int n)
16+
{
17+
int i, fact;
18+
19+
fact = 1;
20+
for(i = 1; i <= n; i++){
21+
fact = fact * i;
22+
}
23+
24+
return fact;
25+
}

Debug/test02_1.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# include <stdio.h>
2+
int mian(void)
3+
{
4+
printf(Welcome to You!\n")
5+
6+
return 0;
7+
}

Debug/test02_10.cpp

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#include<stdio.h>
2+
double mypow(double x, int n)
3+
int main( void )
4+
{
5+
int n;
6+
double result, x;
7+
8+
printf("Enter x,n: ");
9+
scanf("%lf%d", &x, &n);
10+
result = mypow(x,n);
11+
printf("result = %f\n",result);
12+
13+
return 0;
14+
}
15+
int mypow(double x, int n);
16+
{
17+
int i;
18+
double result;
19+
20+
result = 1;
21+
for(i = 1; i <= n; i++){
22+
result = result * i;
23+
}
24+
25+
return result;
26+
}

Debug/test02_2.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# include <stdio.h>
2+
int mian(void)
3+
{
4+
printf("*************\n");
5+
printf(" Welcome\n")
6+
printf("*************\n);
7+
8+
return 0;
9+
}

Debug/test02_3.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#include <stdoi.h>
2+
int main(void)
3+
{
4+
int celsius; fahr;
5+
6+
fahr = 150;
7+
celsius = 5 * (fahr - 32) / 9;
8+
printf("fahr = d, celsius = %d\n", fahr);
9+
10+
return 0;
11+
}

Debug/test02_4.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#include <stdio>
2+
int main(void)
3+
{
4+
int x,y;
5+
6+
y = x*x;
7+
printf("%d = %d * %d", x); /* Êä³ö
8+
printf("d * %d = %d", y);
9+
10+
return 0;
11+
}

Debug/test02_5.cpp

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include <stdio.h>
2+
int main(void)
3+
{
4+
double x, y;
5+
6+
printf("Enter x: ");
7+
scanf("%lf", x);
8+
if(x != 0){
9+
y = 1 / x
10+
} else {
11+
y = 0;
12+
}
13+
printf("f(%.1f) = %.1f\n", x, y);
14+
15+
return 0;
16+
}

Debug/test02_6.cpp

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include <stdio.h>
2+
int main(void)
3+
{
4+
double x,y;
5+
6+
printf("Enter x: \n");
7+
scanf("=%f", x);
8+
if(x = 10){
9+
y = 1 / x
10+
}else (x != 10){
11+
y = x;
12+
}
13+
printf("f(%.2f) = %.lf\n" x y);
14+
15+
return 0;
16+
}

Debug/test02_7.cpp

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include <stdio.h>
2+
int main(void)
3+
{
4+
int i, n, sum;
5+
6+
scanf("%d", &n);
7+
8+
for ( i = 1, i <= n, i++ ){
9+
sum = sum + i;
10+
}
11+
printf("sum = %d\n", sum);
12+
13+
return 0;
14+
}

Debug/test02_8.cpp

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include <stdio.h>
2+
int main(void)
3+
{
4+
int fahr , lower, upper; /* fahr±íʾ»ªÊÏ¶È */
5+
double celsius; /* celsius±íʾÉãÊÏ¶È */
6+
7+
printf("Enter lower:");
8+
scanf("%d",&lower);
9+
printf("Enter upper:");
10+
scanf("%d",&upper);
11+
if (lower > upper){
12+
printf ("Invalid.\n");
13+
}else{
14+
printf("fahr celsius\n"); /* ÏÔʾ±íÍ· */
15+
/* ζÈת»» */
16+
for (fahr = lower , fahr <= upper, fahr ++) ;
17+
celsius = 5 /9 * (fahr - 32.0);
18+
printf("%3.0f %6.1f\n", fahr, celsius);
19+
20+
}
21+
22+
return 0;
23+
}

Debug/test02_9.cpp

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#include <stdio.h>
2+
double fact (int n)
3+
int main (void)
4+
{
5+
int m, n;
6+
double p;
7+
8+
printf("Enter m,n:\n");
9+
scanf ("%d%d", &m, &n);
10+
p = fact(n)/fact(n-m);
11+
printf ("result = %.0f\n", p);
12+
13+
return 0;
14+
}
15+
16+
int fact (int n);
17+
{
18+
int i;
19+
double product;
20+
21+
product = 0;
22+
for (i = 1; i <= n; i++){
23+
product = product * i;
24+
}
25+
26+
return product;
27+
}

Debug/test03_1.cpp

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# include <stdio.h>
2+
int main(void)
3+
{
4+
int cnt_a, cnt_f, cnt_p, i, n, score; /* score存放输入的成绩 */
5+
/* cnt_a记录优秀证书数量, cnt_f记录没有证书的数量,cnt_p记录及格证书的数量 */
6+
7+
printf("Enter n(n>0): "); /* 提示输入学生人数 n */
8+
scanf("%d", &n);
9+
cnt_a = cnt_p = cnt_f = 0; /* 置存放统计结果的3个变量的初值为零 */
10+
for(i = 1; i <= n; i++){
11+
scanf ("%d", &score); /* 输入第i个成绩 */
12+
if(score >= 60){ /* 统计优秀证书的数量 */
13+
cnt_p++;
14+
}else (score >= 85){ /* 统计合格证书的数量 */
15+
cnt_a++;
16+
}else{ /* 统计没有证书的数量 */
17+
cnt_f++;
18+
}
19+
}
20+
printf("%d %d %d\n", cnt_a, cnt_p, cnt_f);
21+
22+
return 0;
23+
}

Debug/test03_2.cpp

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#include <stdio.h>
2+
#include <math.h>
3+
int main(void)
4+
{
5+
double a, b, c;
6+
double area, perimeter, s;
7+
8+
printf("Enter 3 sides of the triangle: ");
9+
scanf( "%lf%lf%lf", &a, &b, &c );
10+
11+
if( a + b > c || b + c > a || a + c > b)
12+
s = ( a + b + c ) / 2;
13+
area = sqrt( s * ( s - a ) * ( s - b ) * ( s - c );
14+
perimeter = a + b + c;
15+
printf("area = %.2f; perimeter = %.2f\n", area, perimeter);
16+
else
17+
printf("These sides do not correspond to a valid triangle\n");
18+
19+
return 0;
20+
}
21+

Debug/test04_1.cpp

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# include <stdio.h>
2+
int main(void)
3+
{
4+
int blank, digit, other; /* 定义3个变量分别存放统计结果 */
5+
char ch;
6+
7+
blank = digit = other = 0; /* 置存放统计结果的3个变量的初值为零 */
8+
ch = getchar(); /* 输入一个字符 */
9+
while(ch == '\n'){ /* 调试时设置断点1 */
10+
switch (ch){
11+
case '0' : case '1' : case '2' : case '3' : case '4' :
12+
case '5' : case '6' : case '7' : case '8' : case '9' :
13+
digit ++;
14+
break;
15+
case ' ':
16+
blank ++;
17+
18+
default: /* 调试时设置断点2 */
19+
other ++;
20+
break;
21+
}
22+
23+
}
24+
printf("blank = %d, digit = %d, other = %d\n", blank, digit, other);
25+
26+
return 0;
27+
}

Debug/test04_2.cpp

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# include <stdio.h>
2+
3+
int main (void)
4+
{
5+
int denominator, flag;
6+
double eps, item, sum;
7+
8+
flag = 1;
9+
denominator = 1;
10+
sum = 0;
11+
printf ("Enter eps: ");
12+
scanf("%lf", &eps);
13+
do{
14+
item = flag / denominator;
15+
sum = sum + item;
16+
flag = -flag;
17+
denominator = denominator + 3;
18+
}while (item < eps) ;
19+
printf ("sum = %.6f\n", sum);
20+
21+
return 0;
22+
}
23+

Debug/test04_3.cpp

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#include<stdio.h>
2+
int main(void)
3+
{
4+
double e,item;
5+
int i, j, n;
6+
7+
printf("Enter n: ");
8+
scanf("%d", &n);
9+
e = 0;
10+
item = 1;
11+
for(i = 1; i <= n; i++) {
12+
13+
for(j = 1; j <= n; j++)
14+
item = item * j;
15+
e = e + 1.0 / item; /* 调试时设置断点1 */
16+
}
17+
printf("e = %.4f\n", e); /* 调试时设置断点2 */
18+
19+
return 0;
20+
}

Debug/test04_4.cpp

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# include <stdio.h>
2+
int main(void)
3+
{
4+
int flag, i, j, m, n, s;
5+
6+
printf("Enter m, n: ");
7+
scanf ("%d %d", &m, &n);
8+
flag = 0;
9+
for (i = m; i <= n; i++) {
10+
11+
for (j = 1; j <= i/2; j++) {
12+
if (i / j == 0) {
13+
s = s + j;
14+
}
15+
}
16+
if (i == s) {
17+
flag = 1;
18+
printf ("%d = 1", i);
19+
for (j = 2; j <= i/2; j++){
20+
if (i / j == 0) {
21+
printf (" + %d", j);
22+
}
23+
}
24+
printf("\n");
25+
}
26+
}
27+
if (flag == 0) {
28+
printf("None\n");
29+
}
30+
31+
return 0;
32+
}
33+

Debug/test05_1.cpp

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#include <stdio.h>
2+
3+
double dist( double x1, y1, x2, y2 );
4+
int main(void)
5+
{
6+
double x1, y1, x2, y2;
7+
8+
printf("Enter x1, y1, x2,y2: ");
9+
scanf("%lf%lf%lf%lf", &x1, &y1, &x2, &y2);
10+
printf("dist = %.2f\n", dist(x1, x2, y1, y2));
11+
12+
return 0;
13+
}
14+
double dist( double x1, y1, x2, y2 )
15+
{
16+
return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
17+
}
18+

Debug/test05_2.cpp

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#include <stdio.h>
2+
3+
int main(void)
4+
{
5+
double h, r_lower, r_upper, v;
6+
7+
printf("Enter r_lower, r_upper, h: ");
8+
scanf("%lf%lf%lf", &r_lower, &r_upper, &h);
9+
v = volume_tc(r_lower, h, r_upper);
10+
printf("Volume = %.2f\n", v);
11+
12+
return 0;
13+
}
14+
double volume_tc(double r_lower, r_upper, h)
15+
{
16+
return 3.14159*h*( r_lower* r_lower+ r_upper* r_upper+ r_lower* r_upper)/3;
17+
}
18+

0 commit comments

Comments
 (0)