#include <stdio.h> int SQ(int y){ return ((y)*(y)); } int main(){ int i=1; while(i<=5){ printf("%d^2 = %d\n", (i-1), SQ(i++)); } return 0; }运行结果:
#include <stdio.h> #define SQ(y) ((y)*(y)) int main(){ int i=1; while(i<=5){ printf("%d^2 = %d\n", i, SQ(i++)); } return 0; }在 Visual Studio 和 C-Free 下的运行结果(其它编译器的运行结果可能不同,这个
++
运算的顺序有关):#include <stdio.h> #define SSSV(s1, s2, s3, v) s1 = length * width; s2 = length * height; s3 = width * height; v = width * length * height; int main(){ int length = 3, width = 4, height = 5, sa, sb, sc, vv; SSSV(sa, sb, sc, vv); printf("sa=%d, sb=%d, sc=%d, vv=%d\n", sa, sb, sc, vv); return 0; }运行结果:
本文链接:http://task.lmcjl.com/news/8244.html