fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. char pieces[] = {'K', 'P', 'N', 'B', 'R', 'Q', 'k', 'p', 'n', 'b', 'r', 'q'};
  6. int scores[] = {0, 1, 3, 3, 5, 9, 0, -1, -3, -3, -5, -9};
  7. char board[8][9];
  8.  
  9. for (int i = 0; i < 8; i++){
  10. cin >> board[i];
  11. }
  12.  
  13. int total = 0;
  14.  
  15. for (int i = 0; i < 8; i++) {
  16. for (int j = 0; j < 8; j++) {
  17. for (int k = 0; k < 12; k++) {
  18. if (board[i][j] == pieces[k]) {
  19. total += scores[k];
  20. break ;
  21. }
  22. }
  23. }
  24. }
  25.  
  26. cout << total;
  27.  
  28. return 0;
  29. }
Success #stdin #stdout 0s 5296KB
stdin
rnbqkbnk
pppppppp
........
........
........
........
PPPPPPPP
RNBQKBNK
stdout
Standard output is empty