Advertisement
Anna3O0

Caractere Fisa 8

Nov 22nd, 2020 (edited)
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.05 KB | None | 0 0
  1. #include <iostream>
  2. #include <string.h>
  3.  
  4. using namespace std;
  5.  
  6. void cuv(char s[256])
  7. {
  8.     char *p;
  9.     int k=0;
  10.     cin.get(s,256);
  11.     p=strtok(s," ");
  12.     while(p)
  13.     {
  14.         if(strchr(p,'a'))
  15.             k++;
  16.         p=strtok(NULL," ");
  17.     }
  18.     cout<<k;
  19. }
  20.  
  21. void abreviere(char s[256])
  22. {
  23.     char *p,s1[256];
  24.     int i=0;
  25.     cin.get(s,256);
  26.     p=strtok(s," ");
  27.     while(p)
  28.     {
  29.         if(p[0]>='A' && p[0]<='Z')
  30.         {
  31.             s1[i]=p[0];
  32.             i++;
  33.         }
  34.         p=strtok(NULL," ");
  35.     }
  36.  
  37.     s[i]=NULL;
  38.  
  39.     cout<<s1;
  40. }
  41.  
  42. void invLit(char s[256])
  43. {
  44.     char *p,aux,s1[256]="";
  45.     cin.get(s,256);
  46.     p=strtok(s," ");
  47.  
  48.     while(p)
  49.     {
  50.         if(strlen(p)>=3)
  51.         {
  52.             aux=p[0];
  53.             p[0]=p[strlen(p)-1];
  54.             p[strlen(p)-1]=aux;
  55.         }
  56.         strcat(s1,p);
  57.         strcat(s1," ");
  58.         p=strtok(NULL," ");
  59.     }
  60.  
  61.     s1[strlen(s1)-1]=NULL;
  62.     strcpy(s,s1);
  63.  
  64.     cout<<s;
  65. }
  66.  
  67. int main()
  68. {
  69.     char s[256];
  70.     invLit(s);
  71.     return 0;
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement