Advertisement
nicuvlad76

Untitled

Nov 27th, 2020
803
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.81 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. #define N 301
  4. using namespace std;
  5. char s[51],t[101], cuv[4][10]={"COLEGIUL", "LICEUL", "NATIONAL", "TEORETIC"};
  6. char *p, aux[51], *q;
  7. int n,poz;
  8. int main()
  9. {
  10.    cin.getline(s,50);
  11.    p=strtok(s," ");
  12.    while(p)
  13.    {
  14.        q=strchr(p,'.');
  15.        if(q)
  16.        {
  17.            strcpy(aux,p);
  18.            poz=q-p;
  19.            p[poz]=0;
  20.           if(p[0]=='C' && strstr(cuv[0],p)) strcpy(aux,cuv[0]);
  21.           else if(p[0]=='L'&& strstr(cuv[1],p)) strcpy(aux,cuv[1]);
  22.           else if(p[0]=='N'&& strstr(cuv[2],p)) strcpy(aux,cuv[2]);
  23.           else if(p[0]=='T'&& strstr(cuv[3],p)) strcpy(aux,cuv[3]);
  24.        }
  25.        else strcpy(aux,p);
  26.        if(n!=0)strcat(t," ");
  27.        strcat(t,aux);
  28.        n++;
  29.        p=strtok(NULL," ");
  30.    }
  31.    cout<<t;
  32.     return 0;
  33. }
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement