Problem 2722 --Structured Program I - Structured Programming

2722: Structured Program I - Structured Programming

"
Time Limit $1$ 秒/Second(s) Memory Limit $512$ 兆字节/Megabyte(s)
提交总数 $92$ 正确数量 $25$
裁判形式 标准裁判/Standard Judge 我的状态 尚未尝试
难度 分类标签 STL

Structured Programming 

In programming languages like C/C++, a goto statement provides an unconditional jump from the "goto" to a labeled statement. For example, a statement "goto CHECK_NUM;" is executed, control of the program jumps to CHECK_NUM. Using these constructs, you can implement, for example, loops.

Note that use of goto statement is highly discouraged, because it is difficult to trace the control flow of a program which includes goto. 

Write a program which does precisely the same thing as the following program (this example is wrtten in C++). Let's try to write the program without goto statements.

void call(int n){ 

    int i = 1;

   CHECK_NUM: 

    int x = i; 

    if ( x % 3 == 0 ){ 

    cout << " " << i; 

    goto END_CHECK_NUM;

 } 

  INCLUDE3: 

   if ( x % 10 == 3 ){ 

   cout << " " << i; 

   goto END_CHECK_NUM;

 } 

    x /= 10;

   if ( x ) goto INCLUDE3; 

 END_CHECK_NUM: 

   if ( ++i <= n )   goto CHECK_NUM; 

   cout << endl; 

}

An integer n is given in a line.
Print the output result of the above program for given integer n.
30
 3 6 9 12 13 15 18 21 23 24 27 30
3 ≤ n ≤ 10000

推荐代码 查看2722 所有题解 上传题解视频得图灵币

本题记录 用 户(点击查看用户) 运行号(点击购买题解) 时 间
算法最快[$0 $ms] 何不忎 779081 2021-11-14 15:46:37
内存最少[$1156 $KB] 方欣 610405 2020-08-18 15:27:54
第一AC 刘成健 315120 2018-11-16 22:16:59
第一挑战 刘成健 315120 2018-11-16 22:16:59

赛题来源/所属竞赛 会津大学《C++ Programming I》 C++程序设计(入门)

竞赛编号 竞赛名称 竞赛时间 访问比赛