MouseyN1

Probleme cu siruri

Nov 29th, 2012
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.42 KB | None | 0 0
  1.  
  2. // contine majusculele din cel initial. Sirul care contine n caractere incepand de la pozitia p din
  3. // sirul initial, n si p se citesc si sirul care contine caracterele celui initial cu exceptia celor n
  4. // incepand de la pozitia p.
  5.  
  6. #include <iostream>
  7. #include <fstream>
  8. #include <cstring>
  9. using namespace std;
  10.  
  11. void p1(char s[])
  12. {
  13.     int ok = 0;
  14.     for(int i = 0; i < strlen(s); i++)
  15.         if(s[i] >= '0' && s[i] <= '9') {
  16.             cout << s[i]; ok = 1;
  17.         }
  18.         cout << endl;
  19.     if(!ok)
  20.         cout << "N-avem cifre ba, iesi acasa.";
  21. }
  22.  
  23. void p2(char s[])
  24. {
  25.     int contor = 0;
  26.     char voc[] = "aeiouAEIOU";
  27.     cout << endl;
  28.     for(int i = 0; i < strlen(s); i++)
  29.     if(strchr(voc, s[i])) {
  30.         cout << s[i];
  31.         contor = 1;
  32.     }
  33.     if(!contor)
  34.         cout << "N-avem vocale, pleaca acasa.";
  35. }
  36.  
  37. void p3(char s[])
  38. {
  39.     char aux[101];
  40.     strcpy(aux, s);
  41.     strrev(aux);
  42.     cout << endl;
  43.     if(strcmp(aux, s) == 0)
  44.         cout << "Este palindrom" << endl;
  45.     else cout << "Nu este palindrom" << endl;
  46. }
  47.  
  48. void p4(char s[])
  49. {
  50.     int ok = 0;
  51.     for(int i = 0; i < strlen(s); i++)
  52.         if(s[i] >= 'A' && s[i] <= 'Z') {
  53.             cout << s[i]; ok = 1;
  54.         }
  55.         cout << endl;
  56.     if(!ok)
  57.         cout << "N-avem majuscule ba, iesi acasa.";
  58. }
  59.  
  60. void p5(char s[])
  61. {
  62.     int p, n, i; cout << endl;
  63.     cin >> p >> n; cout << endl;
  64.     for(i = p; i < p + n; i++)
  65.         cout << s[i];
  66. }
  67.        
  68.  
  69. int main()
  70. {
  71.     char s[101];
  72.     cin.getline(s, 101);
  73.     p1(s);
  74.     p2(s);
  75.     p3(s);
  76.     p4(s);
  77.     p5(s);
  78.     return 0;
  79. }
Advertisement
Add Comment
Please, Sign In to add comment