goto 语句(虽然不提倡使用goto 但是比赛的时候还蛮好用滴)
2016-01-02 19:47
441 查看
/// goto part2;
///part2: printf("Refined analysis:\n");
///格式 goto <标号>;
///其中标号需要申请,在程序开头写label <标号1>,<标号2>,……;
///其中,标号必须为四位以内的正整数。
///在该段落内还需要有<标号>:语句 表示将要转向的方向。
if (size>12)
goto a;
goto b;
a:cost = cost * 1.05;
flag=2;
b:bill = cost *flag;
等价于
if(size>12)
{
cost = cost * 1.05;
flag=2;
}
bill = cost *flag;
//
if(ibex > 14)
goto a;
sheds = 2;
goto b;
a: sheds= 3;
b: help = 2* sheds;
等价于
if(ibex > 14)
sheds=3;
else
sheds=2;
help = 2*sheds;
//
readin: scanf("%d", &score);
if(score > 0)
goto stage2;
lots of statements;
goto readin;
stage2: more stuff;
等价于
scanf("%d", &score);
while(score <= 0)
{
lots of statements;
scanf("%d", &score);
}
more stuff;
就这些了 呵呵哒
///part2: printf("Refined analysis:\n");
///格式 goto <标号>;
///其中标号需要申请,在程序开头写label <标号1>,<标号2>,……;
///其中,标号必须为四位以内的正整数。
///在该段落内还需要有<标号>:语句 表示将要转向的方向。
if (size>12)
goto a;
goto b;
a:cost = cost * 1.05;
flag=2;
b:bill = cost *flag;
等价于
if(size>12)
{
cost = cost * 1.05;
flag=2;
}
bill = cost *flag;
//
if(ibex > 14)
goto a;
sheds = 2;
goto b;
a: sheds= 3;
b: help = 2* sheds;
等价于
if(ibex > 14)
sheds=3;
else
sheds=2;
help = 2*sheds;
//
readin: scanf("%d", &score);
if(score > 0)
goto stage2;
lots of statements;
goto readin;
stage2: more stuff;
等价于
scanf("%d", &score);
while(score <= 0)
{
lots of statements;
scanf("%d", &score);
}
more stuff;
就这些了 呵呵哒
相关文章推荐
- Gone Fishing(Poj1042)(贪心+枚举)
- Google的不作恶文化和10大信条
- django资料
- Generative Learning algorithms
- Django之 创建第一个站点
- Google Hacking
- Golang中的管道channel在几个典型语言中的实现
- Good Bye 2015-------补题
- Webgoat的配置
- Golang之字符串格式化
- Codeforces GoodBye 2015
- 【转】Codeforces GoodBye2015 New Year and Three Musketeers Codeforces 611E(贪心)
- Codeforces GoodBye2015 New Year and Three Musketeers Codeforces 611E(贪心)
- Codeforces GoodBye2015 New Year and Three Musketeers Codeforces 611E(贪心)
- lingo求解最短路和最大流问题
- Django自学习4
- Django学习笔记 Day One
- 【DP】good bye 2015 D
- CF Good Bye 2015 C- New Year and Domino(CF611C)
- Django 数据模型的字段列表整理