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 }

 

相关文章:

  • 2022-02-18
  • 2021-09-27
  • 2021-05-23
  • 2021-10-25
  • 2022-02-17
  • 2021-05-31
  • 2021-11-17
  • 2021-07-01
猜你喜欢
  • 2021-10-14
  • 2022-01-31
  • 2021-10-04
  • 2022-02-22
  • 2021-07-22
  • 2021-09-10
  • 2021-11-21
相关资源
相似解决方案