Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<string.h>
- #include<fstream>
- using namespace std;
- ifstream fin("text.in");
- //ofstream fout("text.out");
- int ordalfa ( char a[51])
- {
- int ok=1, i;
- for(i=0; i<strlen(a)-1; i++)
- if (a[i]>a[i+1])ok=0;
- if(ok) return 1;
- else return 0;
- }
- char s[51][51], rez1[51], rez2[51];
- int main ()
- {
- int n, i, nr=0;
- fin>>n;
- for(i=1;i<=n;i++)
- fin>>s[i];
- for(i=1;i<n;i++)
- {
- strcpy(rez1, s[i]);
- strcat(rez1, s[i+1]);
- strcpy(rez2, s[i+1]);
- strcat(rez2, s[i]);
- if(ordalfa(rez1)||ordalfa(rez2)) nr++;
- }
- cout<<nr;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement