2014-04-24 23:10

题目:找出下面代码里的错误。

解法:请看下面。

代码:

 1 // 12.1 What's wrong with the following code segment?
 2 #include <cstdio>
 3 using namespace std;
 4 
 5 // unsigned int will never be negative, so it's a dead loop.
 6 // "%d" is not right, should be "%u".
 7 int main()
 8 {
 9     unsigned int i;
10     
11     for (i = 100; i >= 0; --i) {
12         printf("%d\n", i);
13     }
14     
15     return 0;
16 }

 

 posted on 2014-04-24 23:14  zhuli19901106  阅读(171)  评论(0编辑  收藏  举报