-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWeek4_1.cpp
More file actions
38 lines (37 loc) · 704 Bytes
/
Copy pathWeek4_1.cpp
File metadata and controls
38 lines (37 loc) · 704 Bytes
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
//Using arithmetic operators
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
main()
{
ifstream aFile("a.txt");
string text;
if(aFile.is_open())
{
getline(aFile,text);
}
string text1,text2;
int checkpoint=0;
for(int i=0;i<text.size();i++)
{
if(text[i]!=' ')
text1.push_back(text[i]);
else
{
checkpoint=i+1;
break;
}
}
for(int i=checkpoint;i<text.size();i++)
{
text2.push_back(text[i]);
}
int num1 = stoi(text1);
int num2 = stoi(text2);
ofstream bFile("b.txt");
if(bFile.is_open())
{
bFile << num1+num2;
}
}