Advertisement
Guest User

problem

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