Главная »
2020 » Апрель » 28 » Файлы. Считывание из файла. Калькулятор
10:06 Файлы. Считывание из файла. Калькулятор |
#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");
}
|
Просмотров: 224 |
Добавил: denjes
| Рейтинг: 0.0/0 |