Advertisement
AliArapov221

TopCoder class generator

Apr 29th, 2024 (edited)
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.26 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. main(){
  5.     //You can print output directly to your file using this:
  6.     //freopen("topcoder.cpp", "w", stdout);
  7.    
  8.     //Copy first four lines after "Definition" in TopCoder statement like this:
  9.     //Class:    XMarksTheSpot
  10.     //Method:   countArea
  11.     //Parameters:   String[]
  12.     //Returns:  int
  13.    
  14.     string s[4];
  15.     for(int i = 0; i < 4; i++) getline(cin, s[i]);
  16.     for(int i = 0; i < (int)s[0].size(); i++){
  17.         if(s[0][i] == ':'){
  18.             i++;
  19.             while(s[0][i] == ' ') i++;
  20.             s[0] = s[0].substr(i, (int)s[0].size() - i);
  21.         }
  22.     }
  23.     for(int i = 0; i < (int)s[1].size(); i++){
  24.         if(s[1][i] == ':'){
  25.             i++;
  26.             while(s[1][i] == ' ') i++;
  27.             s[1] = s[1].substr(i, (int)s[1].size() - i);
  28.         }
  29.     }
  30.     for(int i = 0; i < (int)s[2].size(); i++){
  31.         if(s[2][i] == ':'){
  32.             i++;
  33.             while(s[2][i] == ' ') i++;
  34.             s[2] = s[2].substr(i, (int)s[2].size() - i);
  35.         }
  36.     }
  37.     for(int i = 0; i < (int)s[3].size(); i++){
  38.         if(s[3][i] == ':'){
  39.             i++;
  40.             while(s[3][i] == ' ') i++;
  41.             s[3] = s[3].substr(i, (int)s[3].size() - i);
  42.         }
  43.     }
  44.    
  45.     //Add you template here
  46.    
  47.     cout << "class " << s[0] << "{\n";
  48.     cout << "public:\n";
  49.     cout << "\t" << s[3] << " " << s[1] << "(" << s[2] << "){\n";
  50.     cout << "\t\t\n";
  51.     cout << "\t}\n";
  52.     cout << "};";
  53. }
  54.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement