1. LAB 5:
  2. Q1- Find reminder :
  3. #include <cmath>
  4. #include <cstdio>
  5. #include <vector>
  6. #include <iostream>
  7. #include <algorithm>
  8. using namespace std;
  9. int main() {
  10. int a,b,n,i;
  11. cin >>n;
  12. for (i=1;i<=n;i++)
  13. {
  14. cin>>a>>b;
  15. cout << a%b <<endl;
  16. }
  17. return 0;
  18. }
  19. -----------------------------------------------------------------------------------------
  20. Q2- Chef and Coins Game :
  21. #include <iostream>
  22. using namespace std;
  23. int main() {
  24. int n,t;
  25. cin>>t;
  26. while (t-->0)
  27. {
  28. cin >>n;
  29. if ( n%6==0)
  30. cout << "Misha"<<endl;
  31. else cout << "Chef"<<endl;
  32. }
  33. return 0;
  34. }
  35. -----------------------------------------------------------------------------------------
  36. Q3-Snape and Ladder ( تم استخدام فنكشن الجذر )
  37. #include <cmath>
  38. #include <iostream>
  39. #include <algorithm>
  40. #include <iomanip>
  41. using namespace std;
  42. int main() {
  43. int n,a,b;
  44. cin >>n;
  45. int i;
  46. for (i=1;i<=n;i++)
  47. {
  48. cin >> a >> b;
  49. cout <<setprecision(2)<<fixed<<sqrt(b*b - a*a) << " " << setprecision(2)<<fixed<<sqrt (a*a+b*b)<<endl;
  50. }
  51. return 0;
  52. }
  53. -----------------------------------------------------------------------------------------
  54. Q4-For Loop
  55. #include <iostream>
  56. #include <cstdio>
  57. using namespace std;
  58. int main() {
  59. int i,a,b;
  60. cin >> a >>b;
  61. for (i=a;i<=b;i++)
  62. {
  63. if (i==1)
  64. cout << "one"<<endl;
  65. else if (i==2)
  66. cout << "two"<<endl;
  67. else if (i==3)
  68. cout << "three"<<endl;
  69. else if (i==4)
  70. cout << "four"<<endl;
  71. else if (i==5)
  72. cout << "five"<<endl;
  73. else if (i==6)
  74. cout << "six"<<endl;
  75. else if (i==7)
  76. cout << "seven"<<endl;
  77. else if (i==8)
  78. cout << "eight"<<endl;
  79. else if (i==9)
  80. cout << "nine"<<endl;
  81. else if (i>9)
  82. {
  83. if (i%2==0)
  84. cout << "even"<<endl;
  85. else cout << "odd"<<endl;
  86. }
  87. }
  88. return 0;
  89. }
  90. -----------------------------JEBRIL_MEJDALAWI<3_JCE--------------------------------------
Comments powered by Disqus