Skip to content

Commit 9a330ac

Browse files
committed
[init] unzip form TP312C-C157b
1 parent 63dd826 commit 9a330ac

File tree

290 files changed

+54265
-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.

290 files changed

+54265
-0
lines changed

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
*.o
2+
3+
# msvc
4+
.vscode/
5+
*.ilk
6+
*.pdb
7+
*.obj
8+
*.exe

001/1.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/* The first C programme */
2+
#include <stdio.h> /* 包含标准输入输出头文件 */
3+
main() /* 主函数 */
4+
{
5+
printf("Hello World!\n"); /* 打印输出信息 */
6+
}

002/helloword.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#include "print.h"
2+
3+
int main(void){
4+
printHello();
5+
return 0;
6+
}

002/print.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#include "print.h"
2+
3+
void printHello()
4+
{
5+
printf("hello word!\n");
6+
}

002/print.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#include "stdio.h"
2+
3+
void printHello(void);

003/3.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/* Input two numbers, output the product */
2+
#include <stdio.h>
3+
main()
4+
{
5+
int x,y,m; /* 定义整型变量x,y,m */
6+
printf("Please input x and y\n"); /* 输出提示信息 */
7+
scanf("%d%d",&x,&y); /* 读入两个乘数,赋给x,y变量 */
8+
m=x*y; /* 计算两个乘数的积,赋给变量m */
9+
printf("%d * %d = %d\n",x,y,m); /* 输出结果 */
10+
}

004/4.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/* 输入两个浮点数,输出它们中的大数 */
2+
#include <stdio.h>
3+
main()
4+
{
5+
float x,y,c; /* 变量定义 */
6+
printf("Please input x and y:\n"); /* 提示用户输入数据 */
7+
scanf("%f%f",&x,&y);
8+
c=x>y?x:y; /* 计算c=max(x,y) */
9+
printf("MAX of (%f,%f) is %f",x,y,c); /* 输出c */
10+
}
11+


005/5.C

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/* */
2+
#include <stdio.h>
3+
main()
4+
{
5+
char ch,nch; /* */
6+
int count; /* */
7+
int k; /* */
8+
9+
printf("Please input a string with a # in the end.\n");
10+
scanf("%c",&ch); /* */
11+
while(ch != '#') /* */
12+
{
13+
if(ch >= '0' && ch <= '9')
14+
{
15+
/* */
16+
count = ch-'0'+1; /* */
17+
scanf("%c",&nch); /* */
18+
for(k=0;k<count;k++) /* */
19+
printf("%c",nch);
20+
}
21+
else
22+
printf("%c",ch); /* */
23+
printf(" "); /* */
24+
scanf("%c",&ch); /* */
25+
}
26+
printf("#\n"); /* */
27+
}
28+


006/6.C

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/* 输出不同类型所占的字节数*/
2+
#include <stdio.h>
3+
void main()
4+
{
5+
/* sizeof()是保留字,它的作用是求某类型或某变量类型的字节数, */
6+
/* 括号中可以是类型保留字或变量。*/
7+
/*int型在不同的机器,不同的编译器中的字节数不一样,*/
8+
/*一般来说在TC2.0编译器中字节数为2,在VC编译器中字节数为4 */
9+
printf("The bytes of the variables are:\n");
10+
printf("int:%d bytes\n",sizeof(int));
11+
/* char型的字节数为1 */
12+
printf("char:%d byte\n",sizeof(char));
13+
/* short型的字节数为2 */
14+
printf("short:%d bytes\n",sizeof(short));
15+
/* long型的字节数为4 */
16+
printf("long:%d bytes\n",sizeof(long));
17+
/* float型的字节数为4 */
18+
printf("float:%d bytes\n",sizeof(float));
19+
/* double型的字节数为8 */
20+
printf("double:%d bytes\n",sizeof(double));
21+
/* long double型的字节数为8或10或12 */
22+
printf("long double:%d bytes\n",sizeof(long double));
23+
getchar();
24+
25+
}
26+
27+
28+


007/7.C

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/* */
2+
#include <stdio.h>
3+
main()
4+
{
5+
int a=5,b,c,i=10;
6+
b=a++;
7+
c=++b;
8+
9+
printf("a = %d, b = %d, c = %d\n",a,b,c);
10+
printf("i,i++,i++ = %d,%d,%d\n",i,i++,i++);
11+
printf("%d\n",++i);
12+
printf("%d\n",--i);
13+
printf("%d\n",i++);
14+
printf("%d\n",i--);
15+
printf("%d\n",-i++);
16+
printf("%d\n",-i--);
17+
getchar();
18+
}

008/8.C

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#include <stdio.h>
2+
main()
3+
{
4+
int i,j,n;
5+
long sum=0,temp=0;
6+
7+
printf("Please input a number to n:\n");
8+
scanf("%d",&n);
9+
if(n<1)
10+
{
11+
printf("The n must no less than 1!\n");
12+
return;
13+
}
14+
15+
for(i=1;i<=n;i++)
16+
{
17+
temp=0;
18+
for(j=1;j<=i;j++)
19+
temp+=j;
20+
sum+=temp;
21+
}
22+
printf("The sum of the sequence(%d) is %d\n",n,sum);
23+
getchar();
24+
getchar();
25+
}

009/9.c

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#include <stdio.h>
2+
#include <conio.h>
3+
void main(void)
4+
{
5+
int i,j,x,y;
6+
clrscr();
7+
printf("\n\n * * * ³Ë·¨¿Ú¾÷±í * * * \n\n");
8+
x=9;
9+
y=5;
10+
for(i=1;i<=9;i++)
11+
{
12+
gotoxy(x,y);
13+
printf("%2d ",i);
14+
x+=3;
15+
}
16+
x=7;
17+
y=6;
18+
for(i=1;i<=9;i++)
19+
{
20+
gotoxy(x,y);
21+
printf("%2d ",i);
22+
y++;
23+
}
24+
x=9;
25+
y= 6;
26+
for(i=1;i<=9;i++)
27+
{
28+
for(j=1;j<=9;j++)
29+
{
30+
gotoxy(x,y);
31+
printf("%2d ",i*j);
32+
y++;
33+
}
34+
y-=9;
35+
x+=3;
36+
}
37+
printf("\n\n");
38+
}
39+
40+
41+
42+
43+
44+
45+
46+
47+
48+
49+
50+
51+
52+
53+
54+
55+
56+
57+
58+

010/10.c

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#include <stdio.h>
2+
#include <conio.h>
3+
void main()
4+
{
5+
int Password=0,Number=0,price=58,i=0;
6+
clrscr();
7+
printf("\n====This is a Number Guess Game!====\n");
8+
while( Password != 1234 )
9+
{
10+
if( i >= 3 )
11+
return;
12+
i++;
13+
puts("Please input Password: ");
14+
scanf("%d",&Password);
15+
}
16+
17+
i=0;
18+
while( Number!=price )
19+
{
20+
do{
21+
puts("Please input a number between 1 and 100: ");
22+
scanf("%d",&Number);
23+
printf("Your input number is %d\n",Number);
24+
}while( !(Number>=1 && Number<=100) );
25+
if( Number >= 90 )
26+
{
27+
printf("Too Bigger! Press any key to try again!\n");
28+
}
29+
else if( Number >= 70 && Number < 90 )
30+
{
31+
printf("Bigger!\n");
32+
}
33+
else if( Number >= 1 && Number <= 30 )
34+
{
35+
printf("Too Small! Press any key to try again!\n");
36+
}
37+
else if( Number > 30 && Number <= 50 )
38+
{
39+
printf("Small! Press any key to try again!\n");
40+
}
41+
else
42+
{
43+
if( Number == price )
44+
{
45+
printf("OK! You are right! Bye Bye!\n");
46+
}
47+
else if( Number < price )
48+
{
49+
printf("Sorry,Only a little smaller! Press any key to try again!\n");
50+
51+
}
52+
else if( Number > price )
53+
printf(" Sorry, Only a little bigger! Press any key to try again!\n");
54+
}
55+
getch();
56+
}
57+
}
58+
59+


011/11.c

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#include <stdio.h>
2+
3+
void main()
4+
{
5+
int Password=0,Number=0,price=58,i=0;
6+
7+
while( Password != 1234 )
8+
{
9+
if( i >= 3 )
10+
return;
11+
i++;
12+
puts("Please input Password: ");
13+
scanf("%d",&Password);
14+
}
15+
16+
i=0;
17+
while( Number!=price )
18+
{
19+
do{
20+
puts("Please input a number between 1 and 100: ");
21+
scanf("%d",&Number);
22+
printf("Your input number is %d\n",Number);
23+
}while( !(Number>=1 && Number<=100) );
24+
if( Number >= 90 )
25+
{
26+
printf("Too Bigger! Press any key to try again!\n");
27+
}
28+
else if( Number >= 70 && Number < 90 )
29+
{
30+
printf("Bigger!\n");
31+
}
32+
else if( Number >= 1 && Number <= 30 )
33+
{
34+
printf("Too Small! Press any key to try again!\n");
35+
}
36+
else if( Number > 30 && Number <= 50 )
37+
{
38+
printf("Small! Press any key to try again!\n");
39+
}
40+
else
41+
{
42+
if( Number == price )
43+
{
44+
printf("OK! You are right! Bye Bye!\n");
45+
}
46+
else if( Number < price )
47+
{
48+
printf("Sorry,Only a little smaller! Press any key to try again!\n");
49+
50+
}
51+
else if( Number > price )
52+
printf(" Sorry, Only a little bigger! Press any key to try again!\n");
53+
}
54+
getch();
55+
}
56+
}
57+
58+


0 commit comments

Comments
 (0)