Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2020
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. int main(int argc, char* argv[])
  2. {
  3. char arr[3][3] = {{42, 0, '*'},{'*', 0, 3},{'*', 0, 0}};
  4. int count = 0;
  5. int i = 0, j = 0;
  6. int di[] = {-1,-1,-1,0,1,1,1,0};
  7. int dj[] = {-1,0,1,1,1,0,-1,-1};
  8.  
  9. for (int k = 0; k < 8; ++k)
  10. {
  11. if (arr[i + di[k]][j + dj[k]] == '*') ++count;
  12. }
  13.  
  14.  
  15.  
  16. cout << count << '\n';
  17. system("pause");
  18. return 0;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement