|
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
|
#include <iostream>
#include <string>
using namespace std;
int main()
{
int r,c;
double count = 0;
char* row;
cin >> r;
cin >> c;
if(r < 1 || c < 1)
{
cout << 0 << endl;
return 0;
}
char num;
int cont = 0;
for(int i = 0; i< (r*c); i++) {
cin >> num;cont += num-48;}
/*for(int i = 0; i < r; i++)
{
row = new char[c];
for(int j = 0; j < c; j++)
{
row[j] = 0;
}
cin >> row;
if(cin.eof())
{
break;
}
for(int k = 0; k < c; k++)
{
count += row[k] - 48;
}
delete row;
}*/
cout << cont << endl;
return 0;
}
|