TungstenVn

t_dt2

Oct 20th, 2021 (edited)
687
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.36 KB | None | 0 0
  1. Exercise A:
  2. //start=======================================================
  3. #include <iostream>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     for (int i = 0; i < 3; i++) {
  10.         cout <<"**********\n";
  11.     }
  12.     return 0;
  13. }
  14. //end=========================================================
  15.  
  16. Exercise B:
  17. //start=======================================================
  18. #include <iostream>
  19.  
  20. using namespace std;
  21.  
  22. int leafHeight = 6;
  23. int thunkHeight = 3;
  24.  
  25. void createSpace(int line){
  26.     for(int temp = 0;temp < leafHeight - line;temp++){
  27.         cout << " ";
  28.     }
  29. }
  30. void createDot(int line){
  31.     for(int temp = 0;temp < line - 1;temp++){
  32.         cout << "*";
  33.     }
  34. }
  35. int main()
  36. {  
  37.    
  38.     for(int step = 1;step <= leafHeight;step++){
  39.         cout << "|";
  40.         createSpace(step);
  41.         createDot(step);
  42.         cout << "*";
  43.         createDot(step);
  44.         createSpace(step);
  45.         cout << "|\n";
  46.     }
  47.     for(int step = 1;step <= thunkHeight;step++){
  48.         cout << "|";
  49.         createSpace(1);
  50.         createDot(1);
  51.         cout << "*";
  52.         createDot(1);
  53.         createSpace(1);
  54.         cout << "|\n";
  55.     }
  56.     return 0;
  57. }
  58. //end=========================================================
  59.  
  60. Exercise C:
  61. //start=======================================================
  62. #include <iostream>
  63.  
  64. using namespace std;
  65.  
  66. int main()
  67. {  
  68.     cout << "2468 + 1234 = " << 2468 + 1234 << "\n";
  69.     cout << "2468 - 1234 = " << 2468 - 1234 << "\n";
  70.     cout << "2468 * 1234 = " << 2468 * 1234 << "\n";
  71.     cout << "2468 // 1234 = " << 2468 / 1234 << "\n";
  72.     return 0;
  73. }
  74. //end=========================================================
  75.  
  76. Exercise D:
  77. //start=======================================================
  78. #include <iostream>
  79.  
  80. using namespace std;
  81.  
  82. int main()
  83. {  
  84.     cout << "DT = " << (7.8 * 6.4) << "\n";
  85.     cout << "CV = " << (7.8 + 6.4)*2 << "\n";
  86.     return 0;
  87. }
  88. //end=========================================================
  89.  
  90. Exercise E:
  91. //start=======================================================
  92. #include <iostream>
  93.  
  94. using namespace std;
  95.  
  96. int main()
  97. {  
  98.     int n;
  99.     cin >> n;
  100.     cout << n*3;
  101.     return 0;
  102. }
  103. //end=========================================================
  104.  
  105. Exercise F: sai clg
  106. //start=======================================================
  107. #include <iostream>
  108.  
  109. using namespace std;
  110.  
  111. int main()
  112. {  
  113.     int x, y, z;
  114.     cin >> x >> y >> z;
  115.     cout << (5*x + 3*y) * z;
  116.     return 0;
  117. }
  118. //end=========================================================
  119.  
  120.  
  121. Exercise G:  sai clgt
  122. //start=======================================================
  123. #include <iostream>
  124.  
  125. using namespace std;
  126.  
  127. int main()
  128. {  
  129.     int n;
  130.     cin >> n;
  131.     cout << n*n - n +1;
  132.     return 0;
  133. }
  134. //end=========================================================
  135.  
  136. Exercise H:
  137. //start=======================================================
  138. #include <iostream>
  139.  
  140. using namespace std;
  141.  
  142. int main()
  143. {  
  144.     int n;
  145.     cin >> n;
  146.     cout << to_string(n)[0] << "\n";
  147.     cout << to_string(n)[1] << "\n";
  148.     cout << to_string(n)[2] << "\n";
  149.     return 0;
  150. }
  151. //end=========================================================
  152.  
  153.  
  154. Exercise I:
  155. //start=======================================================
  156. #include <iostream>
  157.  
  158. using namespace std;
  159.  
  160. int main()
  161. {  
  162.     int x,y,z;
  163.     cin >> x;
  164.     cin >> y;
  165.     cin >> z;
  166.     cout << to_string(x)+":"+to_string(y)+":"+to_string(z);
  167.     return 0;
  168. }
  169. //end=========================================================
  170.  
  171. Exercise J:
  172. //start=======================================================
  173. #include <iostream>
  174.  
  175. using namespace std;
  176.  
  177. int main()
  178. {  
  179.    
  180.     int h, m, s, x;
  181.     cin >> h >> m >> s >> x;
  182.     int total_sec = h*60*60 + m*60 +s +x;
  183.     int minutes = (total_sec / 60);
  184.     int hours = (minutes / 60)%12;
  185.     if(hours == 0){
  186.         hours == 12;
  187.     }
  188.     cout << to_string(hours) +" "+ to_string(minutes%60) +" " + to_string(total_sec%60) << endl;
  189.     return 0;
  190. }
  191. //end=========================================================
  192.  
  193. K:
  194. #include <stdio.h>
  195.  
  196. int main()
  197. {
  198.     unsigned long h,w,n;
  199.     scanf("%lu%lu%lu",&h,&w,&n);
  200.     unsigned long result = 0;
  201.     for(unsigned long column = 0;column < h;column = column + n){
  202.         for(unsigned long row = 0;row < w;row = row + n){
  203.             result++;
  204.         }
  205.     }
  206.     printf("%lu",result);
  207.     return 0;
  208. }
Add Comment
Please, Sign In to add comment