fork(2) download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. int Time[8] = { 8,9,10,11,12,2,3,4 };
  6. string Day[6] = { "Monday","Tuesday","Wednesday","Thursday","Friday","Saturday" };
  7.  
  8. string Monday[8] = { "Physics","Chemistry","Maths","English","Programming","French","ECA","Reference" };
  9. string Tuesday[8] = { "English","Maths","Chemistry","Physics","Reference","French","ECA","Programming" };
  10. string Wednesday[8] = { "Physics","ECA","Maths","English","Programming","French","Chemistry","Reference" };
  11. string Thursday[8] = { "Chemistry","Physics","Maths","English","Programming","Reference","ECA","French" };
  12. string Friday[8] = { "Reference","Chemistry","Maths","English","Programming","French","ECA","Physics" };
  13. string Saturday[8] = { "Physics","Programming","Maths","English","Chemistry","French","ECA","Reference" };
  14.  
  15.  
  16. int time(int var1);
  17. int main()
  18. {
  19. int time;
  20. string day;
  21.  
  22. cout << "Enter the Time" << endl;
  23. cin >> time;
  24.  
  25. cout << "Enter the day";
  26. cin >> day;
  27.  
  28.  
  29. bool foundday = false;
  30. bool foundtime = false;
  31. int timesub = 0;
  32. int daysub = 0;
  33.  
  34. for (timesub = 0; timesub < 8; timesub++)
  35. {
  36. if (Time[timesub] == time)
  37. {
  38. foundtime = true;
  39. break;
  40. }
  41. }
  42.  
  43. for (daysub = 0; daysub < 6; daysub++)
  44. {
  45. if (Day[daysub] == day)
  46. {
  47. foundday = true;
  48. break;
  49. }
  50. }
  51.  
  52. if (!foundday || !foundtime)
  53. {
  54. cout << "no activity found for that time and day\n";
  55. return 0;
  56. }
  57.  
  58. string activity;
  59. string next;
  60.  
  61. switch (daysub)
  62. {
  63. case 0: activity = Monday [timesub]; if (timesub < 7) next = Monday [timesub+1]; break;
  64. case 1: activity = Tuesday [timesub]; if (timesub < 7) next = Tuesday [timesub+1]; break;
  65. case 2: activity = Wednesday[timesub]; if (timesub < 7) next = Wednesday[timesub+1]; break;
  66. case 3: activity = Thursday [timesub]; if (timesub < 7) next = Thursday [timesub+1]; break;
  67. case 4: activity = Friday [timesub]; if (timesub < 7) next = Friday [timesub+1]; break;
  68. case 5: activity = Saturday [timesub]; if (timesub < 7) next = Saturday [timesub+1]; break;
  69. default: activity = "Day Not found"; break;
  70. }
  71.  
  72. cout << activity << " " << next << '\n';
  73. }
  74.  
Success #stdin #stdout 0s 3464KB
stdin
9
Saturday
stdout
Enter the Time
Enter the dayProgramming  Maths