You are on page 1of 1

miercuri, 7 decembrie 2022

1 /**
2 Afisarea cuvintelor care se termina in caracterul 'c'.
3 */
4 #include <iostream>
5 #include <cstring>
6 using namespace std;
7
8 int main()
9 {
10 char s[256];
11 cin.getline(s,256);
12 int ok=0, n=strlen(s);
13 cout<<"Cuvintele care se incheie cu 'c': \n";
14 /** (1)
15 char *p= strtok(s," ");
16 while(p!=NULL) {
17 int uc=strlen(p)-1;
18 if(toupper(p[uc])=='C')
19 ok=1, cout<<p<<endl;
20 p=strtok(NULL," ");
21 } // */
22 //** SAU (2) {
23 int i=0;
24 while (i<n) {
25 int j=i;
26 while(s[j]!=' ' && j<n){
27 ++j;
28 }
29 j--;
30 if(s[j]=='c' || s[j]=='C')
31 {
32 for(int k=i; k<=j; k++)
33 ok=1, cout<<s[k];
34 cout<<endl;
35 }
36 i=j+2;
37 }
38 /**//// }
39 if(!ok) cout<<"NU SUNT\n";
40
41 return 0;
42 }
43
44

You might also like