Advertisement
J00ker

Untitled

Jan 12th, 2015
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.92 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. #include <fstream>
  4. #include <cstdlib>
  5.  
  6. using namespace std;
  7.  
  8. void Citire(char* s)
  9. {
  10.     ifstream fin("text.in");
  11.     fin.getline(s, 999);
  12.     fin.close();
  13. }
  14.  
  15. void ElimVoc(char* s)
  16. {
  17.     int nr = strlen(s);
  18.     char voc[] = "aeiou", *p;
  19.     p = strtok(s, voc);
  20.     while(p != NULL)
  21.     {
  22.         p = strtok(NULL, voc);
  23.     }
  24.     for(int i = 0; i < nr; i++)
  25.         if(s[i] != 0) cout << s[i];
  26.  
  27. }
  28.  
  29. void SchLit(char* s)
  30. {
  31.     int i = 0, lM = 1;
  32.     while(s[i] != 0)
  33.     {
  34.         if(s[i] == ' '){ lM = 1; i++; }
  35.         if(lM == 1)
  36.         {
  37.             if(s[i] >= 97) s[i] -= 32;
  38.             lM = 0;
  39.         }
  40.         else
  41.             if(s[i] < 97) s[i] += 32;
  42.         i++;
  43.     }
  44. }
  45.  
  46. int SumCif(char* s)
  47. {
  48.     int i = 0, sm = 0;
  49.     char cuv[100][100], *p;
  50.     p = strtok(s, " ");
  51.     while(p != NULL)
  52.     {
  53.         strcpy(cuv[i], p); i++;
  54.         p = strtok(NULL, " ");
  55.     }
  56.     for(int j = 0; j <= i; j++)
  57.     {
  58.         if(cuv[j][0] >= 48 && cuv[j][0] <= 57) sm += atoi(cuv[j]);
  59.     }
  60.     return sm;
  61. }
  62.  
  63. void Secv(char* s)
  64. {
  65.     int a, amx, b, bmx, lg, mx, i, lM;
  66.     a = b = mx = lg = i = lM = 0;
  67.     if(s[i] <= 90) lM = 1;
  68.     while(s[i] != 0)
  69.     {
  70.         if(lM == 0)
  71.         {
  72.             if(lg > mx)
  73.             {
  74.                 amx = a;
  75.                 bmx = b;
  76.             }
  77.             lg = 0;
  78.             a = b = i+1;
  79.         }
  80.         else
  81.         {
  82.             lg++;
  83.             b++;
  84.         }
  85.         if(s[++i] <= 90) lM = 1;
  86.         else lM = 0;
  87.     }
  88.     for(int cuv = amx; cuv < bmx; cuv++)
  89.         cout << s[cuv];
  90. }
  91. int main()
  92. {
  93.     char s[1000];
  94.     Citire(s);
  95.     cout << s << "\n";
  96.    
  97.     //1
  98.     /*
  99.     ElimVoc(s);
  100.     */
  101.  
  102.     //2
  103.     /*
  104.     SchLit(s);
  105.     cout << s << "\n";
  106.     */
  107.  
  108.  
  109.     //4
  110.     /*
  111.     cout << SumCif(s);
  112.     */
  113.  
  114.     //5
  115.     /*
  116.     Secv(s);
  117.     */
  118.     return 0;
  119. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement