• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Untitled

a guest Nov 13th, 2019 95 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. /* fisierul sir.in contine o fraza formata din mai multe cuvinte separate prin spatiu, virgula, punct, semnul
2. exclamarii, semnul intrebarii.
3. a. afisati cuv din text
4. b. inlocuiti prima si ultima litera a fiecarui cuvant de lungime impara cu majuscula corespunzatoare
5. c. ordonati cuvintele alfabetic si afisatile pe ecran*/
6.
7. #include <bits/stdc++.h>
8. using namespace std;
9.
10. ifstream f("text.in");
11.
12. int main()
13. {
14.     char s[100],sep[]=" .,!?",*p,cuv[30][30],aux[30];
15.     int i=0,n;
16.     //a
17.     f.get(s,100);
18.     p=strtok(s,sep);
19.     while(p){strcpy(cuv[i],p);
20.              cout<<cuv[i]<<endl;
21.              p=strtok(NULL,sep);
22.              i++;}
23.     n=i-1;
24.     //b
25.     if(strlen(cuv[0])%2==1) cuv[0][strlen(cuv[0])-1]=cuv[0][strlen(cuv[0])-1]-32;
26.     for(i=1;i<=n;i++) if(strlen(cuv[i])%2==1) {cuv[i][0]=cuv[i][0]-32;
27.                                               cuv[i][strlen(cuv[i])-1]=cuv[i][strlen(cuv[i])-1]-32;}
28.     cout<<endl;
29.     for(i=0;i<=n;i++) cout<<cuv[i]<<" ";
30.     //c
31.     for(i=0;i<n;i++) for(int j=i+1;j<=n;j++)
32.                      if(strcmp(cuv[i],cuv[j])>0){strcpy(aux,cuv[i]);
33.                                                  strcpy(cuv[i],cuv[j]);
34.                                                  strcpy(cuv[j],aux);}
35.     cout<<endl;
36.     for(i=0;i<=n;i++) cout<<cuv[i]<<" ";
37.     return 0;
38. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.
Not a member of Pastebin yet?