Implementation of bidirectional bubble sorting algorithm in C language

From , 4 Years ago, written in C++, viewed 52 times.
URL https://pastebin.vip/view/51f4efbf
  1. #include<iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.         int i,j,t;
  6.         int a[10];
  7.         cout<<"输入十个数:"<<endl;
  8.     for(i=0;i<10;i++)
  9.           a[i]=10-i;
  10.         for(j=0;j<5;j++)
  11.         {
  12.                 for(i=j;i<=9-j;i++)
  13.                 {
  14.                         if(a[i]>a[i+1])
  15.                         {t=a[i];a[i]=a[i+1];a[i+1]=t;}         
  16.                         if(a[9-i]<a[8-i])
  17.                         {t=a[9-i];a[9-i]=a[8-i];a[8-i]=t;}
  18.                
  19.                 }
  20.                 for(i=0;i<10;i++)
  21.                 cout<<a[i]<<'\t';
  22.         }
  23.         cout<<"最终结果是;"<<endl;
  24.         for(i=0;i<10;i++)
  25.                 cout<<a[i]<<'\t';
  26.         return 0;
  27. }
  28. //cpp/8900

Reply to "Implementation of bidirectional bubble sorting algorithm in C language"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website