Advertisement
dllbridge

Untitled

Jan 2nd, 2023
1,107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.92 KB | None | 0 0
  1.  
  2. #include <iostream>
  3. using namespace std;
  4.  
  5.  
  6. int          kol_vo,
  7.           price = 0;
  8.          
  9.          
  10.          
  11. void        start();                 //  Первая часть программы
  12. int     calc(int n);
  13.  
  14. ///////////////////////////////////////////////////////////////
  15. int main()                                                   //
  16. {
  17.  
  18.     start();
  19.    
  20.     int   delen = kol_vo / 7;
  21.     int ostatok = kol_vo % 7;
  22.  
  23.     price  = calc( 7)* delen;    
  24.     price += calc( ostatok );
  25.  
  26.     cout << "цена: " << price;
  27. }
  28.  
  29.  
  30.  
  31.  
  32. ///////////////////////////////////////////////////////////////
  33. void start()                                                 //
  34. {
  35.        
  36.     setlocale(LC_ALL, "Russian");
  37.    
  38.     cout << "Введите количество книг: ";
  39.     cin  >> kol_vo;
  40.    
  41. }
  42.  
  43.  
  44. ///////////////////////////////////////////////////////////////
  45. int calc(int n)                                              //
  46. {
  47.    
  48.     int p = 0;
  49.    
  50.     if( n < 8)
  51.     {
  52.         for(int i = 0; i < n; i++)
  53.         {
  54.             p += 1000 - 55 * i;
  55.         }
  56.     }  
  57.     else return -1;
  58.    
  59.          return  p;  
  60. }
  61.  
  62.  
  63. /*#1
  64. #include <iostream>
  65. using namespace std;
  66.  
  67.  
  68.  
  69. ///////////////////////////////////////////////////////////////
  70. int main()                                                   //
  71. {
  72.    
  73.     setlocale(LC_ALL, "Russian");
  74.        
  75.     int      kol_vo,
  76.           price = 0;
  77.        
  78.    
  79.     cout << "Введите количество книг: ";
  80.     cin  >> kol_vo;
  81.  
  82.     if(kol_vo < 8)
  83.     {
  84.         for(int i = 0; i < kol_vo; i++)
  85.         {
  86.             price += 1000 - 55 * i;
  87.         }
  88.         cout << "цена: " << price;
  89.         return 0;
  90.     }
  91.  
  92.     if(kol_vo >= 8)
  93.     {
  94.         price = 2000;
  95.         for(int i = 0 ;i < kol_vo - 2 ; i++)
  96.         {
  97.             price += 1000 - (55 * i + 1);
  98.         }
  99.  
  100.         cout << "цена: " << price;
  101.     }
  102. }
  103.  
  104.  
  105.  
  106. */
  107.  
  108.  
  109.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement