1http://learn.tsinghua.edu.cn
Email,qiaolin@cic.tsinghua.edu.cn
Tel,62792961
2http://learn.tsinghua.edu.cn
– C
– C
–
– C
– C
3http://learn.tsinghua.edu.cn
C
– 1973 Ritchie kernighan UNIX
– 1989 ANSI/ISO CC89
– 1999 C++ C99
C
–
4http://learn.tsinghua.edu.cn
–
–
–
5http://learn.tsinghua.edu.cn
–
–
–
–
–
–
6http://learn.tsinghua.edu.cn
ASCII
–
–
–
C89 31 C99 5
–
–
7http://learn.tsinghua.edu.cn
Hello World!” C
#include <stdio.h>
int main()
{
printf(“Hello World! \n”);
return 0;
}
printf() stdio.h”
’\n’
8http://learn.tsinghua.edu.cn
// Get the average value of three floats
#include <stdio.h>
int main()
{
float a,b,c,aver;
printf(“Please input three floats:\n”);
scanf(“%f,%f,%f”,&a,&b,&c);
/* Computing */
aver = (a + b + c) / 3;
printf(“\naverage = %f\n”,aver);
return 0;
}
I/O
9http://learn.tsinghua.edu.cn
#include <stdio.h>
int xmin(int x,int y)
{
int m; if(x<y) m = x; else m = y; return m;
}
int main()
{
int a,b,a_b_min;
printf(“Please input two integers:\n”);
scanf(“%d %d”,&a,&b);
a_b_min = xmin(a,b);
printf(“\nThe min is %d.\n”,a_b_min);
return 0;}
I/O
10http://learn.tsinghua.edu.cn
m ain()
11http://learn.tsinghua.edu.cn
0
12http://learn.tsinghua.edu.cn
–
–
–
–
–
–
13http://learn.tsinghua.edu.cn
14
Email,qiaolin@cic.tsinghua.edu.cn
Tel,62792961
2http://learn.tsinghua.edu.cn
– C
– C
–
– C
– C
3http://learn.tsinghua.edu.cn
C
– 1973 Ritchie kernighan UNIX
– 1989 ANSI/ISO CC89
– 1999 C++ C99
C
–
4http://learn.tsinghua.edu.cn
–
–
–
5http://learn.tsinghua.edu.cn
–
–
–
–
–
–
6http://learn.tsinghua.edu.cn
ASCII
–
–
–
C89 31 C99 5
–
–
7http://learn.tsinghua.edu.cn
Hello World!” C
#include <stdio.h>
int main()
{
printf(“Hello World! \n”);
return 0;
}
printf() stdio.h”
’\n’
8http://learn.tsinghua.edu.cn
// Get the average value of three floats
#include <stdio.h>
int main()
{
float a,b,c,aver;
printf(“Please input three floats:\n”);
scanf(“%f,%f,%f”,&a,&b,&c);
/* Computing */
aver = (a + b + c) / 3;
printf(“\naverage = %f\n”,aver);
return 0;
}
I/O
9http://learn.tsinghua.edu.cn
#include <stdio.h>
int xmin(int x,int y)
{
int m; if(x<y) m = x; else m = y; return m;
}
int main()
{
int a,b,a_b_min;
printf(“Please input two integers:\n”);
scanf(“%d %d”,&a,&b);
a_b_min = xmin(a,b);
printf(“\nThe min is %d.\n”,a_b_min);
return 0;}
I/O
10http://learn.tsinghua.edu.cn
m ain()
11http://learn.tsinghua.edu.cn
0
12http://learn.tsinghua.edu.cn
–
–
–
–
–
–
13http://learn.tsinghua.edu.cn
14