1. LAB 4:
  2. Q1: DAY OF MONTH (USING SWITCH):
  3. #include <cmath>
  4. #include <cstdio>
  5. #include <vector>
  6. #include <iostream>
  7. #include <algorithm>
  8. using namespace std;
  9. int main() {
  10. int n;
  11. cin>>n;
  12. switch (n)
  13. {case 1 :
  14. case 3:
  15. case 5:
  16. case 7:
  17. case 8:
  18. case 10:
  19. case 12: cout << "31 days";break;
  20. case 4:
  21. case 9:
  22. case 6:
  23. case 11: cout << "30 days"; break;
  24. case 2: cout << "28 or 29 days" ; break;
  25. default : cout << "invalid month number";
  26. }
  27. return 0;
  28. }
  29. *****************************************************************************************
  30. Q2:kangaroo :
  31. #include <iostream>
  32. using namespace std;
  33. int main(){
  34. int x1,x2,v1,v2,a,b;
  35. cin>>x1>>v1>>x2>>v2;
  36. a=(x1-x2);
  37. b=(v2-v1);
  38. if (x2>=x1&&v2>=v1) cout<<"NO";
  39. else if (a%b==0) cout<<"YES";
  40. else cout<<"NO";
  41. }
  42. *****************************************************************************************
  43. Q3 :
  44. Ilya and Bank Account :
  45. #include <cmath>
  46. #include <cstdio>
  47. #include <vector>
  48. #include <iostream>
  49. #include <algorithm>
  50. using namespace std;
  51. int main() {
  52. long n,m,v;
  53. cin>>n;
  54. m=n/10;
  55. v= (n/100)*10 + n%10;
  56. if (n>=0)
  57. cout << n;
  58. else { if (v>m)
  59. cout <<v;
  60. else cout << m;
  61. }
  62. return 0;
  63. }
  64. ****************************************************************************************
  65. Q4: MINI-MAX SUM:
  66. #include <iostream>
  67. using namespace std;
  68. int main ()
  69. {
  70. long long arr[5];
  71. long long i,sum=0,max=-999999999999999,min=9999999999999;
  72. for (i=0;i<5;i++)
  73. {
  74. cin >> arr[i];
  75. sum=sum+arr[i];
  76. if (arr[i]>max)
  77. max = arr[i];
  78. if (arr[i]<min)
  79. min = arr[i];
  80. }
  81. cout << sum - max << " " << sum - min;
  82. }
  83. ****************************************************************************************
  84. Q5 : Compare the Triplets:
  85. #include <iostream>
  86. using namespace std;
  87. int main() {
  88. int a0,a1,a2,b0,b1,b2,ap=0,bp=0;
  89. cin >> a0 >> a1 >>a2;
  90. cin >> b0 >> b1 >> b2;
  91. if (a0 > b0)
  92. ap++;
  93. else if (b0>a0)
  94. bp++;
  95. if (a1 > b1)
  96. ap++;
  97. else if (b1>a1)
  98. bp++;
  99. if (a2 > b2)
  100. ap++;
  101. else if (b2>a2)
  102. bp++;
  103. cout << ap << " " << bp;
  104. }
  105. ************************************JEBRIL_MEJDALAWI*************************************