- LAB 4:
- Q1: DAY OF MONTH (USING SWITCH):
- #include <cmath>
- #include <cstdio>
- #include <vector>
- #include <iostream>
- #include <algorithm>
- using namespace std;
- int main() {
- int n;
- cin>>n;
- switch (n)
- {case 1 :
- case 3:
- case 5:
- case 7:
- case 8:
- case 10:
- case 12: cout << "31 days";break;
- case 4:
- case 9:
- case 6:
- case 11: cout << "30 days"; break;
- case 2: cout << "28 or 29 days" ; break;
- default : cout << "invalid month number";
- }
- return 0;
- }
- *****************************************************************************************
- Q2:kangaroo :
- #include <iostream>
- using namespace std;
- int main(){
- int x1,x2,v1,v2,a,b;
- cin>>x1>>v1>>x2>>v2;
- a=(x1-x2);
- b=(v2-v1);
- if (x2>=x1&&v2>=v1) cout<<"NO";
- else if (a%b==0) cout<<"YES";
- else cout<<"NO";
- }
- *****************************************************************************************
- Q3 :
- Ilya and Bank Account :
- #include <cmath>
- #include <cstdio>
- #include <vector>
- #include <iostream>
- #include <algorithm>
- using namespace std;
- int main() {
- long n,m,v;
- cin>>n;
- m=n/10;
- v= (n/100)*10 + n%10;
- if (n>=0)
- cout << n;
- else { if (v>m)
- cout <<v;
- else cout << m;
- }
- return 0;
- }
- ****************************************************************************************
- Q4: MINI-MAX SUM:
- #include <iostream>
- using namespace std;
- int main ()
- {
- long long arr[5];
- long long i,sum=0,max=-999999999999999,min=9999999999999;
- for (i=0;i<5;i++)
- {
- cin >> arr[i];
- sum=sum+arr[i];
- if (arr[i]>max)
- max = arr[i];
- if (arr[i]<min)
- min = arr[i];
- }
- cout << sum - max << " " << sum - min;
- }
- ****************************************************************************************
- Q5 : Compare the Triplets:
- #include <iostream>
- using namespace std;
- int main() {
- int a0,a1,a2,b0,b1,b2,ap=0,bp=0;
- cin >> a0 >> a1 >>a2;
- cin >> b0 >> b1 >> b2;
- if (a0 > b0)
- ap++;
- else if (b0>a0)
- bp++;
- if (a1 > b1)
- ap++;
- else if (b1>a1)
- bp++;
- if (a2 > b2)
- ap++;
- else if (b2>a2)
- bp++;
- cout << ap << " " << bp;
- }
- ************************************JEBRIL_MEJDALAWI*************************************