Advertisement
Junaid_Hossain

G. Bowling Figure

Oct 13th, 2023
681
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.91 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. #include<string.h>
  3.  
  4. using namespace std;
  5.  
  6. int main(){
  7.     int t;
  8.     cin >> t;
  9.  
  10.     while(t--){
  11.         string str;
  12.         cin >> str;
  13.         int overs=0;
  14.         int balls=0;
  15.         overs= str.size()/6;
  16.         balls= str.size()%6;
  17.  
  18.         int run=0;
  19.         int wicket=0;
  20.  
  21.         for(int i=0; i<str.size(); i++){
  22.             if(str[i]=='W'){
  23.                 wicket++;
  24.             }else{
  25.                 int x;
  26.                 x = int(str[i])-48;
  27.                 run=run+x;
  28.             }
  29.         }
  30.         string o= " Over ";
  31.         string r= " Run ";
  32.         string w= " Wicket";
  33.         if((overs+balls*0.1)> 1.0){
  34.             o = " Overs ";
  35.         }
  36.         if((run)> 1){
  37.             r = " Runs ";
  38.         }
  39.         if(wicket> 1){
  40.             w = " Wickets";
  41.         }
  42.         cout << overs << "." << balls  << o << run << r << wicket << w << ".\n";
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement