-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSource5.cpp
More file actions
45 lines (39 loc) · 758 Bytes
/
Source5.cpp
File metadata and controls
45 lines (39 loc) · 758 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
39
40
41
42
43
44
45
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
#include <array>
#include <stdio.h>
#include <vector>
#include <map>
#include <cmath>
using namespace std;
int main() {
int mk,tmp,sum;
ofstream output("MK.OUT");
string umk;
vector <char> arr;
ifstream input("MK.INP");
if (input.is_open())
{
getline(input, umk);
cout << umk << endl;
sum = 0;
int length = umk.length();
cout << length << endl;
for (int i = 0; i< length;i++) {
tmp = (int)umk[i] - 48;
cout << tmp << endl;
sum = sum + tmp;
}
cout << sum;
if (output.is_open())
{
output << sum;
output.close();
}
input.close();
}
else cout << "Unable to open file";
return 0;
}