有人不?在线蹲大佬,c++,怎么跳出???

P1089 [NOIP2004 提高组] 津津的储蓄计划

@[AIMEE11](/user/755327) 跳出循环:break。直接进入下一次循环:continue。
by _Cppsteve_ @ 2022-07-27 15:54:58


@[AIMEE11](/user/755327) 在for循环中使用"break;"跳出循环
by 御坂10029号 @ 2022-07-27 15:55:13


@[AIMEE11](/user/755327) 退出循环:`break;`
by little_cindy @ 2022-07-27 15:55:24


@[AIMEE11](/user/755327) ```cpp #include<bits/stdc++.h> using namespace std; int main() { int c,s=0,h=0; for(int i=1;i<=12;i++) { scanf("%d",&c); s-=c-300; if(s<0) { printf("-%d",i); return 0; } else { h+=s/100; s%=100; } } printf("%d",120*h+s); return 0; } ```
by Auroraxcz2011 @ 2022-07-27 15:55:36


AC代码(请问会有人想对着图片照抄吗): ![](https://gcore.jsdelivr.net/gh/SteveTaizhou/steve-imgbed@main/img/20220727155559.png)
by _Cppsteve_ @ 2022-07-27 15:56:30


高级一点还能用 $goto$
by IcyFoxer_XZY @ 2022-07-27 15:56:52


谢谢,~~果然还是在线蹲有用。~~
by AIMEE11 @ 2022-07-27 15:57:50


@[AIMEE11](/user/755327) 在 `for` 和 `while` 循环中,可以使用 `break` 语句跳出当前这层循环,或者用 `continue` 语句来直接跳转到当前这层循环的下一轮。 使用 `return` 语句可以直接跳出函数,在 `main` 函数中使用可以直接退出程序。如果返回值类型不是 `void`,记得加上返回值。
by _Cppsteve_ @ 2022-07-27 15:58:33


@[_Cppsteve_](/user/479296) 有的有的(@-@)
by AIMEE11 @ 2022-07-27 15:59:16


刚刚写的,只是为了测试一下 ```cpp #include <bits/stdc++.h> #define qwq qw<< #define qw cout using namespace std; int main() { qwq "Helloworld"<<endl; return 0; } ``` P用都没有
by _Cppsteve_ @ 2022-07-27 15:59:39


| 下一页