#include<stdio.h> int main() { int i,sum=0; i=1; do { sum=sum+i;//1+2+3 ..+99+100 i++;//2 3 4 ... 100 101(跳出循环) } while (i<=100);//sum=1+2+...+100 printf("%d\n",sum); }
do {sum=sum+i; i++; }while(i<=100);//i=101时,就会跳出循环,不会再加101了