1、C语言课前习题,辽宁科技大学 黄建,以下程序的运行结果是: int a = 1, b = 1, c = 1; if (a = 2) printf(%d, a = 3); else printf(%d, a != 1); if (b-) b+2; b+; printf(%d, +b = 2); switch (c 0) case 1: printf(%d, (1,2),3); break; case 0: printf(%d, +c); ,3. 分支语句,312,4. 循环语句,填空实现:输出x的y次方的后3位数。 main() int i, x, y, s = ; scanf(%d%d, );
2、 for (i = 1; i = 1; i-) sum = 0; for (j = 1; j = i; j+) sum += i * j; printf(%d, sum);,1,6. 数组,以下程序的运行结果是: int a10 = 1,1,1,2,2,3,3,3,3; int b4 = 0, i; for (i = 0; i 10; i+) bai+; for (i = 0; i 0) fun(x/2); printf(%d, x); main() fun(3); ,13,8. 编译预处理,以下程序的运行结果是: #include #define PT 3.5; #define S(x) P
3、T*x*x; main() int a = 1, b = 2; printf(%4.1fn, S(a+b); A)14.0 B)31.5 C) 7.5 D)程序有错,无输出结果,9. 指针与数组,以下程序的运行结果是: int a5 = 1,3,5,7,9, *p = a, i; for (i = 0; i 4; i+) p0 += p1; p+; for (i = 0; i y); printf(%dn, (+p)-x); ,10,3,14. 链表,现要将q和r所指结点的前后位置交换,同时要保持链表的连续,以下错误的程序段是 A)q-next=r-next; p-next=r; r-next=q; B)q-next=r-next; r-next=q; p-next=r; C)r-next=q; q-next=r-next; p-next=r; D)p-next=r; q-next=r-next; r-next=q;,