Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 4.71 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include<stdio.h>
  3. #include<stdlib.h>
  4.  
  5. Main()
  6. {
  7.     int c;
  8.     char * a;
  9.  
  10.     printf("A farmer has come across a river, he has a duck, a bag of corn and a wolf, on the bank of the river is a rowboat that can hold only 1 additional thing . The duck cannot be left with the corn as it will eat the corn, nor can the duck be left with the wolf as the wolf will eat the duck. You must now solve this.");
  11.     printf("From now on the Duck, Corn and Wolf shall be numbers");
  12.     printf("Duck = 1\nCorn = 2\nWolf = 3\nWhat do you want to take across first?");
  13.  
  14.  
  15.     do
  16.     {
  17.         scanf("%d", &c);
  18.         if (c == 1)
  19.         {
  20.             printf("You have taken the duck across the pond\nDo you want to take anything back with you? y or n");
  21.             do
  22.             {
  23.                 scanf("%s", &a);
  24.                 if (a = "y")
  25.                 {
  26.                     printf("You have taken the duck back across the pond");
  27.                     Main();
  28.                 }
  29.                 else if (a = "n")
  30.                 {
  31.                     printf("You row back across the pond, all that is left is the fox and the corn, what do you take next? 2 or 3");
  32.                     do
  33.                     {
  34.                         if (c == 2)
  35.                         {
  36.                             printf("You have taken the corn across the river\nDo you take anything back with you? y or no");
  37.                            
  38.                             do
  39.                             {
  40.                                 scanf("%s", &a);
  41.                                 if (a = "y")
  42.                                 {
  43.                                     printf("You have chosen to take something back with you, do you take back the duck or the corn? 1 or 2");
  44.                                     do
  45.                                     {
  46.                                         scanf("%d", &c);
  47.                                         if (c == 1)
  48.                                         {
  49.                                             printf("You have taken back the duck");
  50.                                             printf("You now have on the bank a duck and a wolf, which do you take across? 1 or 3");
  51.                                             do
  52.                                             {
  53.                                                 if (c == 1)
  54.                                                 {
  55.                                                     printf("Seriously, you just brought the duck back over, now you want to send it back again, im breaking the crazy train here so you can start over.");
  56.                                                     system("pause");
  57.                                                     exit(0);
  58.                                                 }
  59.                                                 else if (c == 3)
  60.                                                 {
  61.                                                     printf("You take the wolf across the river to the other side and drop it off\n then you row back and pick up the duck and take that across\nCONGRATULATIONS YOU SOLVED THE PUZZLE!");
  62.                                                 }
  63.  
  64.                                             }while (c != 1 || c != 3);
  65.                                         }
  66.                                         else if (c == 2)
  67.                                         {
  68.                                             printf("Seriously a bit stupid taking something back across the river that you brought with you on the same trip, maybe rethink this when you startup the program again");
  69.                                             system("pause");
  70.                                             exit(0);
  71.                                         }
  72.                                     } while (c != 1 || c != 2);
  73.  
  74.                                 }
  75.                                 else if (a = "n")
  76.                                 {
  77.                                     printf("You have left the duck and the corn alone, as soon as you leave the duck starts eating the corn");
  78.                                     system("pause");
  79.                                     exit(0);
  80.                                 }
  81.                             } while (a != "y" || a != "n");
  82.                         }
  83.                        
  84.                         else if (c == 3)
  85.                         {
  86.                             printf("You have taken the wolf across the river\nDo you take anything back with you? y or no");
  87.                             scanf("%s", &a);
  88.                             do
  89.                             {
  90.                                 if (a == "y")
  91.                                 {
  92.                                     printf("You have chosen to take something back with you, do you take back the duck or the wolf? 1 or 3");
  93.                                     do
  94.                                     {
  95.                                         scanf("%d", &c);
  96.                                         if (c == 1)
  97.                                         {
  98.                                             printf("You have taken back the duck");
  99.                                             printf("You now have on the bank a duck and the corn, which do you take across? 1 or 2");
  100.                                             do
  101.                                             {
  102.                                                 if (c == 1)
  103.                                                 {
  104.                                                     printf("Seriously, you just brought the duck back over, now you want to send it back again, im breaking the crazy train here so you can start over.");
  105.                                                     system("pause");
  106.                                                     exit(0);
  107.                                                 }
  108.                                                 else if (c == 2)
  109.                                                 {
  110.                                                     printf("You take the corn across the river to the other side and drop it off\n then you row back and pick up the duck and take that across\nCONGRATULATIONS YOU SOLVED THE PUZZLE!");
  111.                                                 }
  112.  
  113.                                             } while (c != 1 || c != 2);
  114.                                         }
  115.                                         else if (c == 3)
  116.                                         {
  117.                                             printf("Seriously a bit stupid taking something back across the river that you brought with you on the same trip, maybe rethink this when you startup the program again");
  118.                                             system("pause");
  119.                                             exit(0);
  120.                                         }
  121.                                     } while (c != 1 || c != 3);
  122.                                 }
  123.                                 else if (a == "n")
  124.                                 {
  125.                                     printf("You have left the duck and the wolf alone, as soon as you leave the wolf starts eating the duck");
  126.                                     system("pause");
  127.                                     exit(0);
  128.                                 }
  129.                             } while (a != "y" || a != "n");
  130.                         }
  131.  
  132.                     } while (c != 2 || c != 3);
  133.                 }
  134.             } while (a != "y" || a != "n");
  135.         }
  136.         else if (c == 2)
  137.         {
  138.  
  139.         }
  140.         else if (c == 3)
  141.         {
  142.  
  143.         }
  144.  
  145.     } while (c != 1 || c != 2 || c != 3);
  146. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement