正在加载图片...
2.2简单算法举例 例:求两个数的和语言程序 算法1: #include <stdio.h> 输出结果: stepl:给定两个数的值 void main( step2:做加法运算 i int x, y, z 2+3=5 step3:将结果保存 step4:输出结果 Xty; 算法2: printf(《z%dⅦn”,z); stepl:2→x,3→ printf(“od+%d=%dn y, z) step2: x+y(2+3) step3:5→Z step4:输出z2.2 简单算法举例 算法1: step1:给定两个数的值 step2:做加法运算 step3:将结果保存 step4:输出结果 算法2: step1:2 → x ,3 → y step2:x+y (2+3) step3:5 → z step4:输出 z C语言程序 #include <stdio.h> void main( ) { int x, y, z; x=2; y=3; z=x+y; printf(“z=%d\n”, z); printf(“%d+%d=%d\n”, x, y, z); } 输出结果: z=5 2+3=5 例:求两个数的和
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有