Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // contine majusculele din cel initial. Sirul care contine n caractere incepand de la pozitia p din
- // sirul initial, n si p se citesc si sirul care contine caracterele celui initial cu exceptia celor n
- // incepand de la pozitia p.
- #include <iostream>
- #include <fstream>
- #include <cstring>
- using namespace std;
- void p1(char s[])
- {
- int ok = 0;
- for(int i = 0; i < strlen(s); i++)
- if(s[i] >= '0' && s[i] <= '9') {
- cout << s[i]; ok = 1;
- }
- cout << endl;
- if(!ok)
- cout << "N-avem cifre ba, iesi acasa.";
- }
- void p2(char s[])
- {
- int contor = 0;
- char voc[] = "aeiouAEIOU";
- cout << endl;
- for(int i = 0; i < strlen(s); i++)
- if(strchr(voc, s[i])) {
- cout << s[i];
- contor = 1;
- }
- if(!contor)
- cout << "N-avem vocale, pleaca acasa.";
- }
- void p3(char s[])
- {
- char aux[101];
- strcpy(aux, s);
- strrev(aux);
- cout << endl;
- if(strcmp(aux, s) == 0)
- cout << "Este palindrom" << endl;
- else cout << "Nu este palindrom" << endl;
- }
- void p4(char s[])
- {
- int ok = 0;
- for(int i = 0; i < strlen(s); i++)
- if(s[i] >= 'A' && s[i] <= 'Z') {
- cout << s[i]; ok = 1;
- }
- cout << endl;
- if(!ok)
- cout << "N-avem majuscule ba, iesi acasa.";
- }
- void p5(char s[])
- {
- int p, n, i; cout << endl;
- cin >> p >> n; cout << endl;
- for(i = p; i < p + n; i++)
- cout << s[i];
- }
- int main()
- {
- char s[101];
- cin.getline(s, 101);
- p1(s);
- p2(s);
- p3(s);
- p4(s);
- p5(s);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment