csansoon

P3.06 P13623 Chess board (2)

Oct 2nd, 2018
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.35 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main () {
  5.         int a, b, s;
  6.         cin >> a >> b;
  7.         s=0;
  8.         char n;
  9.         for (int i=0; i<a; ++i) {
  10.                 for (int j=0; j<b; ++j) {
  11.                         cin >> n;
  12.                         if (i%2==j%2) s=s+(n-'0');
  13.                 }
  14.         }
  15.         cout << s << endl;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment