Advertisement
Josif_tepe

Untitled

Mar 4th, 2024
495
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.40 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4.  
  5. int main() {
  6.     char c1, c2, c3, c4;
  7.     cin >> c1 >> c2 >> c3 >> c4;
  8.     int najmala_suma = 0, najgolema_suma = 0;
  9.     if(isdigit(c1)) {
  10.         int broj = c1 - '0';
  11.         najmala_suma += broj;
  12.         najgolema_suma += broj;
  13.     }
  14.     else if(c1 == 'P') {
  15.         najmala_suma += 1;
  16.         najgolema_suma += 1;
  17.     }
  18.     else {
  19.         najmala_suma += 2;
  20.         najgolema_suma += 5;
  21.     }
  22.    
  23.     if(isdigit(c2)) {
  24.         int broj = c2 - '0';
  25.         najmala_suma += broj;
  26.         najgolema_suma += broj;
  27.     }
  28.     else if(c2 == 'P') {
  29.         najmala_suma += 1;
  30.         najgolema_suma += 1;
  31.     }
  32.     else {
  33.         najmala_suma += 2;
  34.         najgolema_suma += 5;
  35.     }
  36.     if(isdigit(c3)) {
  37.         int broj = c3 - '0';
  38.         najmala_suma += broj;
  39.         najgolema_suma += broj;
  40.     }
  41.     else if(c3 == 'P') {
  42.         najmala_suma += 1;
  43.         najgolema_suma += 1;
  44.     }
  45.     else {
  46.         najmala_suma += 2;
  47.         najgolema_suma += 5;
  48.     }
  49.     if(isdigit(c4)) {
  50.         int broj = c4 - '0';
  51.         najmala_suma += broj;
  52.         najgolema_suma += broj;
  53.     }
  54.     else if(c4 == 'P') {
  55.         najmala_suma += 1;
  56.         najgolema_suma += 1;
  57.     }
  58.     else {
  59.         najmala_suma += 2;
  60.         najgolema_suma += 5;
  61.     }
  62.     cout << najmala_suma << endl;
  63.     cout << najgolema_suma << endl;
  64.    
  65.     return 0;
  66. }
  67.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement