Josif_tepe

Untitled

Nov 15th, 2025
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.66 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main(){
  4.  
  5.     char c[4];
  6.    
  7.     for(int i = 0; i < 4; i++) {
  8.         cin >> c[i];
  9.     }
  10.    
  11.     int najmala_suma = 0;
  12.     int najgolema_suma = 0;
  13.    
  14.     for(int i = 0; i < 4; i++) {
  15.         if(isdigit(c[i])) {
  16.             najmala_suma += (c[i] - '0');
  17.             najgolema_suma += (c[i] - '0');
  18.         }
  19.         else if(c[i] == 'P') {
  20.             najmala_suma += 1;
  21.             najgolema_suma += 1;
  22.         }
  23.         else if(c[i] == 'R') {
  24.             najmala_suma += 2;
  25.             najgolema_suma += 5;
  26.         }
  27.     }
  28.     cout << najmala_suma << " " << najgolema_suma << endl;
  29.     return 0;
  30. }
  31.  
Advertisement
Add Comment
Please, Sign In to add comment