Advertisement
rekenber

Simple program in Vala, with errors...

Mar 25th, 2011
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Vala 1.31 KB | None | 0 0
  1. class test0
  2. {
  3.   public static void main(string[] args)
  4.   {
  5.     stdout.printf("Greetings! How many cycles would you like? INPUT: ");
  6.     int q=0;
  7.     stdin.scanf("%d", out q);
  8.     test_exec(q);
  9.   }
  10.  
  11.  
  12.   public void test_exec(int q)
  13.   {
  14.     char choice;
  15.     stdout.printf("Iterative or Recursive [I/R]? INPUT: ");
  16.     stdin.scanf("%c", out choice);
  17.     if(choice == 'I' || choice == 'i' && choice =='R' || choice == 'r')
  18.     {
  19.       stdout.printf("--START--\n");
  20.       if(choice == 'I' || choice == 'i')
  21.       {
  22.         stdout.printf("Processing cycles iteratively.");
  23.         iter_cycle(q);
  24.       }
  25.       if(choice == 'R' || choice == 'r')
  26.       {
  27.         stdout.printf("Processing cycels recursively.");
  28.         recur_cycle(q);
  29.       }
  30.     }
  31.     else
  32.     {
  33.       test_exec(q);
  34.     }
  35.   }
  36.  
  37.   public void iter_cycle(int q)
  38.   {
  39.     for(int red = q; red > 0 || q > 0 ; red--)
  40.     {
  41.       stdout.printf("Cycle %d\n", red);
  42.       if(red == 0 && q != 0)
  43.       {
  44.         red = q--;
  45.         stdout.printf("--NEXT--\n");
  46.       }
  47.     }
  48.   }
  49.  
  50.   public void recur_cycle(int q)
  51.   {
  52.     for(int red=q; red > 0; red--)
  53.     {
  54.       stdout.printf("Cycle %d\n", red);
  55.       if(red == 0 && q != 0)
  56.       {
  57.         red = q--;
  58.         stdout.printf("--NEXT--\n");
  59.         recur_cycle(q);
  60.       }
  61.     }
  62.   }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement