Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class test0
- {
- public static void main(string[] args)
- {
- stdout.printf("Greetings! How many cycles would you like? INPUT: ");
- int q=0;
- stdin.scanf("%d", out q);
- test_exec(q);
- }
- public void test_exec(int q)
- {
- char choice;
- stdout.printf("Iterative or Recursive [I/R]? INPUT: ");
- stdin.scanf("%c", out choice);
- if(choice == 'I' || choice == 'i' && choice =='R' || choice == 'r')
- {
- stdout.printf("--START--\n");
- if(choice == 'I' || choice == 'i')
- {
- stdout.printf("Processing cycles iteratively.");
- iter_cycle(q);
- }
- if(choice == 'R' || choice == 'r')
- {
- stdout.printf("Processing cycels recursively.");
- recur_cycle(q);
- }
- }
- else
- {
- test_exec(q);
- }
- }
- public void iter_cycle(int q)
- {
- for(int red = q; red > 0 || q > 0 ; red--)
- {
- stdout.printf("Cycle %d\n", red);
- if(red == 0 && q != 0)
- {
- red = q--;
- stdout.printf("--NEXT--\n");
- }
- }
- }
- public void recur_cycle(int q)
- {
- for(int red=q; red > 0; red--)
- {
- stdout.printf("Cycle %d\n", red);
- if(red == 0 && q != 0)
- {
- red = q--;
- stdout.printf("--NEXT--\n");
- recur_cycle(q);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement