SHOW:
|
|
- or go back to the newest paste.
| 1 | - | #include <iostream> |
| 1 | + | #include <iostream> |
| 2 | - | using namespace std; |
| 2 | + | using namespace std; |
| 3 | - | void get_values(int *array, int number_of_elements) |
| 3 | + | |
| 4 | - | {
|
| 4 | + | int age[] = {17,24};
|
| 5 | - | int i; |
| 5 | + | string name[] = {"roma","dima"};
|
| 6 | - | for (i = 0; i < number_of_elements; i++) |
| 6 | + | |
| 7 | - | {
|
| 7 | + | //*************************************************************************************** |
| 8 | - | cout << "vvedite znachenie " << i << ": "; |
| 8 | + | |
| 9 | - | cin >> array[i]; |
| 9 | + | void main2() |
| 10 | {
| |
| 11 | cout << endl << "punct list" << endl | |
| 12 | - | int main(void) |
| 12 | + | << "1 - baza dannix" << endl |
| 13 | - | {
|
| 13 | + | << "2 - dopolnitelnie funkchii" << endl << endl |
| 14 | - | char a = 0; |
| 14 | + | << "vvedite punct: "; |
| 15 | - | do |
| 15 | + | |
| 16 | - | {
|
| 16 | + | int punct; |
| 17 | - | int numbers[3]; |
| 17 | + | cin >> punct; |
| 18 | - | get_values(numbers, 3); |
| 18 | + | |
| 19 | - | cout << "znachenie massiva: " << endl; |
| 19 | + | cout << endl; |
| 20 | - | for (int i = 0; i < 3; i++) |
| 20 | + | |
| 21 | - | cout << numbers[i] << endl; |
| 21 | + | if(punct < 1 || punct > 2) |
| 22 | {
| |
| 23 | - | int average = 0; |
| 23 | + | cout << "error" << endl; |
| 24 | - | for(int i = 0;i < 3;i++) |
| 24 | + | } |
| 25 | - | {
|
| 25 | + | if(punct == 2) |
| 26 | - | average += numbers[i] ; |
| 26 | + | {
|
| 27 | - | } |
| 27 | + | function(); |
| 28 | - | cout << average << endl; |
| 28 | + | } |
| 29 | - | cout << "prodolzit? " << endl; |
| 29 | + | if(punct == 1) |
| 30 | - | cin >> a; |
| 30 | + | {
|
| 31 | - | } while (a == 'd'); |
| 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 | } |