//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include <tchar.h>
#include <iostream.h>
#include <stdio.h>
#include <fstream.h>
#include <stdlib.h>
//---------------------------------------------------------------------------
#pragma argsused
int _tmain(int argc, _TCHAR* argv[])
{
//открываем файл
FILE *input = fopen("D:\\input.txt", "r");
//подготавливаем переменную для записи в нее значения из файла
char str[1024];
fgets(str, 1023, input) ;
int x;
char plus;
//Приводим отпарсенные данные к целому типу
int one = static_cast<int>(str[0]-'0');
int two = static_cast<int>(str[2]-'0');
//Узнаем знаки
plus=str[1];
int result;
if (plus == '+') {
result = one+two;
}
if (plus == '-') {
result = one-two;
}
int i;
int j=0;
int p;
int p2;
for (i = 0; i < 100; i++) {
if (!str[i]) {
break;
}
else
{
j++;
}
}
int *s3 = new int [j];
for (p = 0; p < j; p++) {
s3[p] = str[p];
}
for (p2 = 0; p2 < j; p2++) {
if (str[p2] != '+' & str[p2] != '-' & str[p2] != '*'& str[p2] != '/') {
s3[p2] = static_cast<int>(str[p2]-'0');
}
else {
s3[p2] = str[p2];
}
}
int c;
int sum1;
int itog=0;
int end = 0;
int k;
int sam = 0;
int raz = 0;
int temp2;
int sum=0;
int l;
for (c = 0; c < j-1; c++) {
if (c%2 != 0) {
end++;
}
}
char temp;
for (c = 0; c < j; c++) {
if (c%2 != 0) {
if (s3[c] == '*') {
if (s3[c+2] != '*' && s3[c+2] != '/') {
if (raz == 0) {
itog = s3[c-1]*s3[c+1]+sum;
s3[c+1] = itog;
sum=0;
}
if (raz != 0) {
itog = raz - s3[c-1]*s3[c+1]+sum;
s3[c+1] = itog;
sum=0;
raz = 0;
}
}
else {
itog = s3[c-1]*s3[c+1];
s3[c+1] = itog;
}
}
if (s3[c] == '/') {
if (s3[c+2] != '*' && s3[c+2] != '/') {
if (raz==0) {
itog = s3[c-1]/s3[c+1]+sum;
s3[c+1] = itog;
}
if (raz!= 0 ) {
itog = raz-s3[c-1]/s3[c+1]+sum;
s3[c+1] = itog;
}
}
else {
itog = s3[c-1]/s3[c+1];
s3[c+1] = itog;
}
}
if (s3[c] == '+') {
sum=0;
if (s3[c+2] == '*' || s3[c+2] == '/' ) {
sum = sum+s3[c-1];
}
if (s3[c+2] != '*' && s3[c+2] != '/') {
itog = s3[c-1]+ s3[c+1] +sum;
s3[c+1] = itog;
}
}
if (s3[c] == '-') {
if (s3[c+2] == '*' || s3[c+2] == '/' ) {
raz = raz+s3[c-1];
}
if (s3[c+2] != '*' && s3[c+2] != '/') {
itog = s3[c-1]- s3[c+1] +sum;
s3[c+1] = itog;
}
}
}
}
cin>> x;
}
//---------------------------------------------------------------------------