~cpp #include<stdio.h> void sum(){ int n=0,sum=0; while(1){ n++; if(sum>=3000){ break; } sum+=n; } printf("n=%d sum=%d\n",n,sum); } int main(){ sum(); return 0; }
~cpp #include<stdio.h> void sum(){ int n=0,sum=0; while(1){ n++; if(sum>=3000){ break; } sum+=n; } printf("n=%d sum=%d\n",n,sum); } int main(){ sum(); return 0; }