Advertisement
rotti321

UVT 2017 sept

Nov 23rd, 2021
579
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ///Admitere UVT 2017
  2. ///S3 a
  3. #include <iostream>
  4. #include <cstring>
  5.  
  6. using namespace std;
  7.  
  8. bool verif(char s[]) {
  9.     char *p;
  10.     int cnt = 0;
  11.     p = strstr(s, ".pdf");
  12.     if(s[0] != 'C' || s[1] != 'V') return false;
  13.     if(p == NULL) return false;
  14.     if(p != NULL && strlen(p) > 4) return false;
  15.     for(int i = 2; i < strlen(s) - 4; i++) {
  16.         if(s[i] == '_') {
  17.             cnt++;
  18.         }
  19.         else {
  20.             if(!(s[i] >= 'a' && s[i] <= 'z')) return false;
  21.         }
  22.     }
  23.     if(cnt > 2) return false;
  24.     return true;
  25. }
  26. void nume(char s[]){
  27.     char *p, cuv[100];
  28.     p=strtok(s, "_"); //CV
  29.     p=strtok(NULL, "_");
  30.     strcpy(cuv, p);
  31.     cuv[0]=cuv[0]-('a'-'A');
  32.     cout<<cuv<< " ";
  33.     p=strtok(NULL, "_.");
  34.     strcpy(cuv, p);
  35.     cuv[0]=cuv[0]-('a'-'A');
  36.     cout<<cuv;
  37. }
  38.  
  39. int main() {
  40.     char s[101] = {};
  41.     int ok = 0;
  42.     cin.getline(s, 100);
  43.     if(verif(s)) ok = 1;
  44.     nume(s);
  45. }
Advertisement
RAW Paste Data Copied
Advertisement