Главная » 2019 » Май » 7 » Файл. Калькулятор
09:27
Файл. Калькулятор

#include <iostream>
#include <fstream>
using namespace std;
int main()
{
    ifstream f;
    f.open("d:\\test2.txt");
    char str1[80],str2[80],d;
    f >> str1; 
    f >> d;
    f >> str2;
    cout<<str1<<d<<str2<<"=";
    int a=atoi(str1), b=atoi(str2);
    if (d=='+') cout<<a+b<<endl;
    if (d=='-') cout<<a-b<<endl;
    if (d=='*') cout<<a*b<<endl;
    if (d=='/') cout<<a/b<<endl;
    f.close();
    system("pause");
}

Просмотров: 307 | Добавил: denjes | Рейтинг: 0.0/0
Всего комментариев: 0
avatar