Advertisement
dllbridge

Untitled

Mar 4th, 2023
869
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 8.09 KB | None | 0 0
  1.  
  2.  
  3. #define _CRT_SECURE_NO_WARNINGS  
  4.  
  5. #include    <stdio.h>
  6. #include   <string.h>
  7.  
  8.  
  9.  
  10. struct Ct
  11. {
  12.    
  13.    int nOld;   
  14.    
  15.    char sz[77];
  16.    
  17. }u1, u2, au[4];
  18.  
  19.      
  20.      
  21. Ct u3;             
  22.  
  23. ////////////////////////////////////////////////////
  24. int main()                                        //
  25. {
  26.    
  27.    
  28.     Ct u4; 
  29.    
  30.        
  31.     u2.nOld = 12;
  32.     strcpy(u2.sz, "Ivan");
  33.  
  34.     printf("u2.nOld = %d\nu2.sz = %s\n", u2.nOld, u2.sz);
  35. }
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64. /*
  65.  
  66. #include   <stdio.h>
  67.  
  68.  
  69. int arr[2][4] = {0, 1, 2, 3,
  70.                  4, 5, 6, 7};
  71.                
  72.  
  73. ////////////////////////////////////////////////////
  74. int main()                                        //
  75. {
  76.    
  77.     int i1 = 0;
  78.  
  79.     for(int i = 0; i < 2; i++)
  80.     {
  81.        
  82.         i1 = 0;
  83.        
  84. Dima:    
  85.      
  86.        
  87.  
  88.         printf("arr[%d][%d] = %d\n", i, i1, arr[i][i1]);
  89.        
  90.         ++i1;
  91.         if(i1 < 4) goto Dima;
  92.        
  93.      
  94.     }
  95.  
  96.  
  97.  
  98. }
  99.  
  100.  
  101.  
  102. */
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111. /*
  112.  
  113. #include   <stdio.h>
  114.  
  115.  
  116. int arr[2][4] = {0, 1, 2, 3,
  117.                  4, 5, 6, 7};
  118.                
  119.  
  120.  
  121. ////////////////////////////////////////////////////
  122. int main()                                        //
  123. {
  124.  
  125.     for(int i = 0; i < 2; i++)
  126.     {
  127.       for(int i1 = 0; i1 < 4; i1++)
  128.       {
  129.        
  130.  
  131.         printf("arr[%d][%d] = %d\n", i, i1, arr[i][i1]);
  132.        
  133.       }
  134.     }
  135.  
  136.  
  137.  
  138. }
  139.  
  140.  
  141.  
  142. */
  143.  
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161. /*
  162.  
  163.  
  164. #include   <stdio.h>
  165.  
  166.  
  167. int arr[12] = {444, 1, 2, 3, 555};
  168.  
  169.  
  170. int *p = arr;
  171.  
  172.  
  173. ////////////////////////////////////////////////////
  174. int main()                                        //
  175. {
  176.  
  177.  
  178.  
  179.     printf("arr = %d\n", arr);
  180.     printf("  p = %d\n",   p);
  181.    
  182.     printf("*arr = %d\n", *arr);
  183.     printf("  *p = %d\n",   *p);    
  184.  
  185. }
  186.  
  187. */
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206.  
  207. /*
  208.  
  209.  
  210. #include   <stdio.h>
  211.  
  212.  
  213.  
  214.  
  215.  
  216. int arr[12] = {0, 1, 2, 3, 555};
  217.  
  218.  
  219.  
  220. ////////////////////////////////////////////////////
  221. int main()                                        //
  222. {
  223.  
  224.     for(int i = 0; i < 10; i++)
  225.     {
  226.        
  227.        printf("arr[%d] = %4d, address = %d\n", i, arr[i], &arr[i]);
  228.        
  229.     }
  230.  
  231. }
  232.  
  233.  
  234.  
  235. */
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269.  
  270.  
  271.  
  272.  
  273.  
  274.  
  275.  
  276.  
  277.  
  278. /*
  279.  
  280. #include <iostream>
  281. using namespace std;
  282.  
  283.  
  284. #include <stdio.h>
  285.  
  286.  
  287. int n;
  288. int one   = 1000;     //стоимость за 1 книгу
  289. int two   = 1945;     //стоимость за 2 книгу
  290. int three = 2835;     //стоимость за 3 книгу
  291. int four  = 3670;     //стоимость за 4 книгу
  292. int five  = 4450;     //стоимость за 5 книгу
  293. int six   = 5175;     //стоимость за 6 книгу
  294. int seven = 5845;     //стоимость за 7 книгу
  295.  
  296.  
  297.  
  298. //  стоимость от 1 до 7 книг
  299. //////////////////////////////////////////////
  300. int foo(int n)                              //
  301. {
  302.     int s     =    0,
  303.         price = 1000;
  304.    
  305.     for(int i = 0; i < n; i++)
  306.     {
  307.  
  308.        s = s + price;
  309.        price = price - 55;  
  310.     }
  311. return s;  
  312. }
  313.  
  314.  
  315.  
  316.  
  317.  
  318. ////////////////////////////////////////////
  319. int main()
  320. {
  321.     int price = foo(5);
  322.  
  323.     printf("price = %d\n", price);
  324. }
  325.  
  326. */
  327. /*
  328.  
  329.  
  330. #include <iostream>
  331. using namespace std;
  332.  
  333.  
  334. //#include <stdio.h>
  335.  
  336.  
  337. int n;
  338. int one   = 1000;     //стоимость за 1 книгу
  339. int two   = 1945;     //стоимость за 2 книгу
  340. int three = 2835;     //стоимость за 3 книгу
  341. int four  = 3670;     //стоимость за 4 книгу
  342. int five  = 4450;     //стоимость за 5 книгу
  343. int six   = 5175;     //стоимость за 6 книгу
  344. int seven = 5845;     //стоимость за 7 книгу
  345.  
  346.  
  347.  
  348.  
  349.  
  350. ////////////////////////////////////////////
  351. int main()
  352. {
  353.     setlocale(LC_ALL, "rus");
  354.     cout << "Введите количество книг: ";
  355.     cin  >> n;
  356.  
  357.  
  358.  
  359.  
  360.     if (n < 1)
  361.     {
  362.         cout << "Ошибка" << endl;
  363.        
  364.     }
  365.     if (n == 1)
  366.     {
  367.         cout << "Цена за 1 книгу: " << one << endl;
  368.  
  369.     }
  370.     if (n == 2)
  371.     {
  372.         cout << "Цена за 2 книги: " << two << endl;
  373.    
  374.     }
  375.     if (n == 3)
  376.     {
  377.         cout << "Цена за 3 книги: " << three << endl;
  378.        
  379.     }
  380.     if (n == 4)
  381.     {
  382.         cout << "Цена за 4 книги: " << four << endl;
  383.        
  384.     }
  385.     if (n == 5)
  386.     {
  387.         cout << "Цена за 5 книг: " << five << endl;
  388.    
  389.     }
  390.     if (n == 6)
  391.     {
  392.         cout << "Цена за 6 книг: " << six << endl;
  393.  
  394.     }
  395.     if (n == 7)
  396.     {
  397.         cout << "Цена за 7 книг: " << seven << endl;
  398.  
  399.     }
  400.    
  401.  
  402.     //////////////////////////////////////////////////////////////
  403.                                                                 //
  404.     else if(n > 7)
  405.     {
  406.         int a = n / 7;
  407.         int b = n % 7;
  408.  
  409.         switch (b)
  410.         {
  411.             case 1: cout << "Цена: " << (a * seven) + one   << endl; break;
  412.             case 2: cout << "Цена: " << (a * seven) + two   << endl; break;
  413.             case 3: cout << "Цена: " << (a * seven) + three << endl; break;
  414.             case 4: cout << "Цена: " << (a * seven) + four  << endl; break;
  415.             case 5: cout << "Цена: " << (a * seven) + five  << endl; break;
  416.             case 6: cout << "Цена: " << (a * seven) + six   << endl; break;
  417.             case 0: cout << "Цена: " << (a * seven)         << endl; break;
  418.         }
  419.  
  420.  }
  421. }
  422.  
  423. */
  424.  
  425.  
  426.  
  427.  
  428.  
  429.  
  430.  
  431.  
  432.  
  433.  
  434.  
  435.  
  436.  
  437.  
  438.  
  439.  
  440. /*
  441. #include <iostream>
  442. using namespace std;
  443.  
  444.  
  445. //#include <stdio.h>
  446.  
  447.  
  448. int n;
  449. int one   = 1000;     //стоимость за 1 книгу
  450. int two   = 1945;     //стоимость за 2 книгу
  451. int three = 2835;     //стоимость за 3 книгу
  452. int four  = 3670;     //стоимость за 4 книгу
  453. int five  = 4450;     //стоимость за 5 книгу
  454. int six   = 5175;     //стоимость за 6 книгу
  455. int seven = 5845;     //стоимость за 7 книгу
  456.  
  457.  
  458.  
  459.  
  460.  
  461. ////////////////////////////////////////////
  462. int main()
  463. {
  464.     setlocale(LC_ALL, "rus");
  465.     cout << "Введите количество книг: ";
  466.     cin >> n;
  467.  
  468.     if (n < 1)
  469.     {
  470.         cout << "Ошибка" << endl;
  471.         //printf("Ошибка\n");
  472.     }
  473.     if (n == 1)
  474.     {
  475.         cout << "Цена за 1 книгу: " << one << endl;
  476.         //printf("Цена за 1 книгу: \n",one);
  477.     }
  478.     if (n == 2)
  479.     {
  480.         cout << "Цена за 2 книги: " << two << endl;
  481.         //printf("Цена за 1 книгу: \n",two);
  482.     }
  483.     if (n == 3)
  484.     {
  485.         cout << "Цена за 3 книги: " << three << endl;
  486.         //printf("Цена за 3 книги: \n", three);
  487.     }
  488.     if (n == 4)
  489.     {
  490.         cout << "Цена за 4 книги: " << four << endl;
  491.         //printf("Цена за 4 книги: \n", four);
  492.     }
  493.     if (n == 5)
  494.     {
  495.         cout << "Цена за 5 книг: " << five << endl;
  496.         //printf("Цена за 5 книг5: \n", five);
  497.     }
  498.     if (n == 6)
  499.     {
  500.         cout << "Цена за 6 книг: " << six << endl;
  501.         //printf("Цена за 6 книг: \n", six);
  502.     }
  503.     if (n == 7)
  504.     {
  505.         cout << "Цена за 7 книг: " << seven << endl;
  506.         //printf("Цена за 7 книг: \n", seven);
  507.     }
  508.    
  509.  
  510.     //////////////////////////////////////////////////////////////
  511.                                                                 //
  512.     else if(n > 7)
  513.     {
  514.         int a = n / 7;
  515.         int b = n % 7;
  516.  
  517.         switch (b)
  518.         {
  519.             case 1: cout << "Цена: " << (a * seven) + one   << endl; break;
  520.             case 2: cout << "Цена: " << (a * seven) + two   << endl; break;
  521.             case 3: cout << "Цена: " << (a * seven) + three << endl; break;
  522.             case 4: cout << "Цена: " << (a * seven) + four  << endl; break;
  523.             case 5: cout << "Цена: " << (a * seven) + five  << endl; break;
  524.             case 6: cout << "Цена: " << (a * seven) + six   << endl; break;
  525.             case 0: cout << "Цена: " << (a * seven)         << endl; break;
  526.         }
  527.  
  528.  }
  529. }
  530.  
  531. */
  532.  
  533.  
  534.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement