daily pastebin goal
28%
SHARE
TWEET

Untitled

a guest Feb 22nd, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<iostream>
  2. #include<fstream>
  3. #include<cstring>
  4.  
  5. using namespace std;
  6. ifstream fin("sortarecuvinte1.in");
  7. ofstream fout("sortarecuvinte1.out");
  8.  
  9. void sort(char A[][31], int n)
  10. {
  11.     for(int i=2; i<=n; i++)
  12.     {
  13.         for(int j=i; j>=2; j--)
  14.         {
  15.             if(strcmp(A[j-1],A[j])==1)
  16.             {
  17.                 char s[31];
  18.                 strcpy(s,A[j]);
  19.                 strcpy(A[j],A[j-1]);
  20.                 strcpy(A[j-1],s);
  21.             }
  22.         }
  23.     }
  24. }
  25.  
  26. char A[201][31];
  27. int main()
  28. {
  29.     int cnt=0;
  30.     while(fin>>A[++cnt])
  31.         true;
  32.     cnt--;
  33.     sort(A,cnt);
  34.     for(int i=1; i<=cnt; i++)
  35.         fout<<A[i]<<endl;
  36.  
  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. OK, I Understand
 
Top