polusik120796
?>

Какой последовательность чисел даст вам вызов функции ранг 8​

Информатика

Ответы

e3913269
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 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 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 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 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 #include<fstream> #include <iostream> #include<vector> #include <stack> #include<string> #include<algorithm> using namespace std; stack<int>st; int error = 0; void operation(string command) {     if (command == "DROP")     {         if (st.size() > 0)         {             st.pop(); return;         }         else         {             error = 1; return;         }     }     if (command == "SWAP")     {         if (st.size() >= 2)         {             int a = st.top();             st.pop();             int b = st.top();             st.pop();             st.push(a);             st.push(b);             return;         }         else         {             error = 1; return;         }     }     if (command == "DUP")     {         if (st.size() > 0)         {             int a = st.top();             st.push(a);             return;         }         else         {             error = 1;             return;         }     }     if (command == "OVER")     {         if (st.size() >= 2)         {             int a = st.top();             st.pop();             int b = st.top();             st.pop();             st.push(b);             st.push(a);             st.push(b);             return;         }         else         {             error = 1; return;         }     }     if (command == "+")     {         if (st.size() >= 2)         {             int a = st.top();             st.pop();             int b = st.top();             st.pop();             st.push(a + b);         }         else         {             error = 1;             return;         }     }     if (command == "-")     {         if (st.size() >= 2)         {             int a = st.top();             st.pop();             int b = st.top();             st.pop();             st.push(b - a); return;         }         else         {             error = 1;             return;         }     }     if (command == "*")     {         if (st.size() >= 2)         {             int a = st.top();             st.pop();             int b = st.top();             st.pop();             st.push(b*a); return;         }         else         {             error = 1;             return;         }       }     if (command == "/")     {         if (st.size() >= 2)         {             int a = st.top();             st.pop();             int b = st.top();             st.pop();             st.push(b/a); return;         }         else         {             error = 1;             return;         }     } } bool isnumber(string x) {     for (int i = 0; i < x.length(); i++)     {         if (x[i] > '9' || x[i] < '0')         {             return false;         }     }     return true; } int main() {     vector<int>v;     ifstream in;     ofstream out;     in.open("input.txt");     out.open("output.txt");         string command;     while (in >> command&&error != 1)     {         if (isnumber(command) == true)         {             st.push(atoi(command.c_str())); continue;         }         operation(command);     }     if (error == 1)     {         out << "ERROR"; return 0;     }     if (st.size() == 0)     {         out << "EMPTY"; return 0;     }     while (st.size() != 0)     {         v.push_back(st.top());         st.pop();     }     reverse(v.begin(), v.end());     for (int i = 0; i < v.size(); i++)     {         out << v[i] << " ";     }     in.close();     out.close(); }

Ответить на вопрос

Поделитесь своими знаниями, ответьте на вопрос:

Какой последовательность чисел даст вам вызов функции ранг 8​
Ваше имя (никнейм)*
Email*
Комментарий*

Популярные вопросы в разделе

Бурмистрова-Ирина660
andrew55588201824
VEZZDEXOD73
Immortal3331
Вакуленко
utkinslava
ldstroy
Mbkozlov6
naratnikova
Rik200081490
mado191065
levsha-27509
balabinatanya7174
rinata542
Irina_Chernyaev532