Petro_zzz

lesson20_322

Sep 29th, 2023
1,060
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.11 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. #define _USE_MATH_DEFINES
  4. #include <math.h>
  5.  
  6. using namespace std;
  7.  
  8. /*
  9. using std::cout;
  10. using std::cin;
  11. using std::endl;
  12. */
  13.  
  14. double d = M_PI;
  15.  
  16. //void ff;
  17. //#define cout std::cout
  18.  
  19. #define begin {
  20. #define end }
  21. #define пока while
  22.  
  23. int my_sum_couter = 0;
  24.  
  25. int my_sum(int a, int b) {
  26.     /*
  27.     void mult(int c, int d) {
  28.     }
  29.     */
  30.  
  31.     //int a = 3;
  32.     //int b = 4;
  33.     my_sum_couter++;
  34.     return a + b;
  35. }
  36.  
  37. void print() {
  38.     int x = 0;
  39.     пока(x < 10) begin
  40.         cout << x++;
  41.     end
  42.     cout << endl;
  43.  
  44.     cout << my_sum << endl;
  45.  
  46.     cout << my_sum_couter << endl;
  47.    
  48.     cout << "3 + 4 = " << my_sum(3, 4) << endl;
  49.     cout << "1 + 5 = " << my_sum(1, 5) << endl;
  50.     cout << "4 + 5 = " << my_sum(4, 5) << endl;
  51.    
  52.     cout << my_sum_couter << endl;
  53. }
  54.  
  55. void draw_rectangle(int w, int h, char ch) {
  56.     for (int y = 0; y < h; y++) {
  57.         for (int x = 0; x < w; x++) {
  58.             cout << ch << " ";
  59.         }
  60.         cout << endl;
  61.     }
  62. }
  63.  
  64. int val = 5;
  65.  
  66. void task_global() {
  67.     int val = 6;
  68.     //std::endl;
  69.     cout << val << " " << ::val << endl;
  70. }
  71.  
  72. void showinverse(int size, int arr[]) {
  73.     for (int k = size - 1; k >= 0; k--)
  74.         cout << arr[k] << ","; 
  75.     cout << endl;
  76. }
  77.  
  78. void showinverse2(int size, int arr[]) {
  79.     for (int k = 0; k < size; k++)
  80.         cout << arr[size - 1 - k] << ",";
  81.     cout << endl;
  82. }
  83.  
  84. void show_tabs() {
  85.     for (int k = 1; k <= 8; k++) {
  86.         for (char ch = 'A'; ch <= 'H'; ch++) {
  87.             cout << ch << k << " ";
  88.         }
  89.         cout << endl;
  90.     }      
  91. }
  92.  
  93. void test_showinverse() {
  94.     int arr[]{ 1,2,3,4 };
  95.     showinverse2(size(arr), arr);
  96.     // 4,3,2,1,
  97. }
  98.  
  99. void sum_userinput() {
  100.     static int sum = 0;
  101.     //sum = 0; -
  102.     int a;
  103.     cin >> a;
  104.     sum += a;
  105.     cout << sum << endl;
  106. }
  107.  
  108. void test_cout_atribut() {
  109.     int x = 250;
  110.     cout << x << endl;
  111.     cout << hex << x << dec << endl;
  112.     cout << x << endl;
  113.     cout << dec << x << endl;  
  114.     cout << (cout.width(5), x);
  115.     cout << (cout.width(5), x);
  116. }
  117.  
  118. int main() {
  119.     //void rr;
  120.     print();
  121.     draw_rectangle(3, 7, '&');
  122.     task_global(); 
  123.     cout << val << endl;
  124.     test_showinverse();
  125.     show_tabs();
  126.  
  127.     //sum_userinput();
  128.     //sum_userinput();
  129.     //sum_userinput();
  130.  
  131.     test_cout_atribut();
  132.  
  133.     return 0;
  134. }
Advertisement
Add Comment
Please, Sign In to add comment