12.1 Find the mistake(s) in the following code:

unsigned int i;
for (i = 190; i >= 0; --i)
printf("%d\n", i);

 

这道题让我们找出给定的简短的程序的错误,这里共有两处错误:

1. 无符号整型永远大于0,所以i >= 0没有意义

2. 打印无符号整型要用%u

正确代码参见下方:

 

unsigned int i;
for (i = 190; i > 0; --i)
printf("%u\n", i);

 

相关文章:

  • 2021-08-04
  • 2021-10-24
  • 2021-07-13
  • 2022-12-23
  • 2022-12-23
  • 2021-09-23
  • 2021-12-26
  • 2022-03-01
猜你喜欢
  • 2022-01-20
  • 2021-07-17
  • 2022-02-15
  • 2022-01-30
  • 2021-09-18
  • 2021-10-27
  • 2021-07-02
相关资源
相似解决方案