机械C 第一讲.ppt

机械C 第一讲

#include stdio.h int main( ) { int a,b,sum; a = 123; b = 456; sum = a + b; printf(”sum is %d\n”,sum); return 0; } 用sum的值替代 希望输出的字符 思考题 1.求三个整数之和 2.求十个整数之和 3.求一千个整数之和 4.求两个整数之差 5.求两个整数之积 例3:求任意两个数中的大值。 /*the example calculate the maximum of a and b*/ #include stdio.h /* This is the main program */ main() { int a,b,c; scanf(“%d%d”,a,b); c=max(a,b); printf(”max= %d\n,c); } /* This function calculates the max of x and y */ int max(int x,int y) {

文档评论(0)

1亿VIP精品文档

相关文档