SHARE
TWEET

sortiranje

a guest May 22nd, 2019 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <cstring>
  3. using namespace std;
  4. int N;
  5. char (*a)[20] = new char [N][20];
  6.  
  7.  
  8.  
  9. void bubb_sort(int rijec)
  10. {
  11.     for (int j=0;j<strlen(a[rijec]);j++)
  12.     {
  13.  
  14.         for (int i=0; i<strlen(a[rijec])-1; i++)
  15.         {
  16.             if (a[rijec][i]>a[rijec][i+1])
  17.             {
  18.                 char pom=a[rijec][i+1];
  19.                 a[rijec][i+1]=a[rijec][i];
  20.                 a[rijec][i]=pom;
  21.             }
  22.            
  23.             /*cout<<"-------------"<<endl;
  24.             cout<<"i="<<i<<endl;
  25.             cout<<"i+1="<<i+1<<endl;
  26.             cout<<"-------------"<<endl;*/
  27.         }
  28.     }
  29. }
  30.  
  31.  
  32. int main()
  33. {
  34.     do
  35.     {
  36.         cin>>N;
  37.     }while(!(N<20));
  38.    
  39.     for(int i=0; i<N; i++)
  40.         cin>>a[i];
  41.    
  42.     for (int i=0; i<N; i++)
  43.         bubb_sort(i);
  44.    
  45.     for (int i=0; i<N; i++)
  46.         cout<<a[i]<<endl;
  47.        
  48.    
  49.     return 0;
  50. }
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top