| |

VerySource

 Forgot password?
 Register
Search
View: 4554|Reply: 23

Is there a general way to change GOTO into a loop? What should I do?

[Copy link]

2

Threads

2

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-1-3 21:00:02
| Show all posts |Read mode
Help newbies! I can't find it everywhere!
Reply

Use magic Report

0

Threads

7

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-1-3 21:51:01
| Show all posts
No
Reply

Use magic Report

0

Threads

9

Posts

10.00

Credits

Newbie

Rank: 1

Credits
10.00

 China

Post time: 2020-1-3 22:15:01
| Show all posts
To see what conditions cause goto, you can use do while etc. instead. That condition is usually while (condition)
Reply

Use magic Report

0

Threads

57

Posts

27.00

Credits

Newbie

Rank: 1

Credits
27.00

 China

Post time: 2020-1-4 00:42:01
| Show all posts
See the logical structure and then change
Goto for looping is changed with while for
But in special cases, the goto method is better, such as read value loop
Reply

Use magic Report

0

Threads

18

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

Post time: 2020-1-29 12:36:01
| Show all posts
Add BREAK or CONTINUE with a loop. The key to always being able to do this is to understand the procedures.
Reply

Use magic Report

0

Threads

78

Posts

29.00

Credits

Newbie

Rank: 1

Credits
29.00

 China

Post time: 2020-1-30 18:00:01
| Show all posts
GOTO changed to loop,
This seems to be very problematic ...

goto is a statement jump,
There is no way for loops to achieve jumps ...
Even break can only end the loop,
It's impossible to skip the statements after the loop ...

However, the specific situation is analyzed specifically,
In some special cases,
It is possible to eliminate goto ...
Reply

Use magic Report

1

Threads

10

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

Post time: 2020-1-31 11:00:01
| Show all posts
Can only be changed to recursion
Reply

Use magic Report

0

Threads

15

Posts

13.00

Credits

Newbie

Rank: 1

Credits
13.00

 China

Post time: 2020-2-1 13:18:01
| Show all posts
·! ·

Is this a problem in itself? ? ?

Basically there is no need to use goto to achieve, at least I have not encountered
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-4-16 19:15:01
| Show all posts
For simple goto situations, it can be easily changed to a while loop, such as:
A: ......

if (B)
  goto A
This can be changed to do {……} while (B)
But if there is an unfinished loop between the A and if statements (if there is {but not} in a loop, or {not}}, then it must be carefully analyzed and it is difficult to find a general method
Reply

Use magic Report

0

Threads

8

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-6-14 11:31:13
| Show all posts
Generally can be modified while while if condition
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list