Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我必须用这个脚本添加数字:
for(i=1; i<1000 ;i++) sum=sum+i;
它将在 32768 处溢出,之后会变为 -32768,因为它不能超过 16 位限制。
我想用一个 int c 来计算溢出。
谢谢
您可以检查 sum > sum + i