Advertisement
Guest User

baza

a guest
Jul 4th, 2013
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int age[] = {17,24};
  5. string name[] = {"roma","dima"};
  6.  
  7. //***************************************************************************************
  8.  
  9. void main2()
  10. {
  11.     cout << endl << "punct list" << endl
  12.     << "1 - baza dannix" << endl
  13.     << "2 - dopolnitelnie funkchii" << endl << endl
  14.     << "vvedite punct: ";
  15.        
  16.     int punct;
  17.     cin >> punct;
  18.        
  19.     cout << endl;
  20.        
  21.     if(punct < 1 || punct > 2)
  22.     {
  23.         cout << "error" << endl;
  24.     }
  25.     if(punct == 2)
  26.     {
  27.         function();
  28.     }  
  29.     if(punct == 1)
  30.     {
  31.         baza();
  32.     }
  33. }
  34.  
  35. //***************************************************************************************
  36.    
  37. void baza()
  38. {
  39.         {
  40.            
  41.             cout << "vvedite id: ";
  42.             int id;
  43.             cin >> id;
  44.            
  45.             if(id > 0 && id < 3)
  46.             {
  47.                 cout << endl << "age: " << age[id-1] << endl << "name: " << name[id-1] << endl;
  48.             }
  49.            
  50.             if(id < 1 || id > 2)
  51.             {
  52.                 cout << "error" << endl;
  53.             }
  54.            
  55.             cout << endl << "hotite prodolzit?: ";
  56.             string vopros;
  57.             cin >> vopros;
  58.            
  59.             do
  60.             {
  61.                 if(vopros == "net")
  62.                 {
  63.                     main2();
  64.                 }
  65.                 if(vopros != "da")
  66.                 {
  67.                     cout << "error(baza)" << endl;
  68.                 }
  69.                 if(vopros == "da")
  70.                 {
  71.                     cout << endl;
  72.                     baza();
  73.                 }
  74.             }
  75.             while(true);
  76.         }
  77. }
  78.  
  79. //********************************************************************************
  80.  
  81. void function()
  82. {
  83.     cout << "list" << endl
  84.             << "dopolnitelnie funkchii" << endl
  85.             << "1 - naiti samogo starshego" << endl
  86.             << "2 - naiti srednij vozrast" << endl << endl
  87.             << "vvedite punct: ";
  88.            
  89.             int punct;
  90.             cin >> punct;
  91.            
  92.             if(punct < 1 || punct > 2)
  93.             {
  94.                 cout << "error" << endl;
  95.             }
  96.            
  97.             if(punct == 1)
  98.             {
  99.                 int a = 0;
  100.                 int b = 0;
  101.                 for(int i = 0 ; i < 2 ; i++)
  102.                 {
  103.                     if(a < age[i])
  104.                     {
  105.                         a = age[i];
  106.                         b = i;
  107.                     }
  108.                 }
  109.                 cout << endl << "age: " << age[b] << endl << "name: " << name[b] << endl;
  110.             }
  111.             if(punct == 2)
  112.             {
  113.                     int resultat = 0;
  114.                     for(int i = 0 ; i < 2 ; i++)
  115.                     {
  116.                         resultat += age[i];
  117.                     }
  118.                     resultat /= 2;
  119.                     cout << "srednij vozrast: "<< resultat << endl;
  120.             }
  121. }
  122.  
  123. //********************************************************************************
  124.  
  125. int main()
  126. {
  127.     main2();
  128. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement