zoukankan      html  css  js  c++  java
  • 冒泡排序

    #include<iostream>
    
    using namespace std;
    int main(int count,char *[])
    {
       int a[10]={9,8,7,6,5,4,3,2,1,0};
       int temp=0;
       int n=10;
       for(int i=0;i<n-1;i++)
       {
          for(int j=0;j<n-i-1;j++)
          {
             if(a[j]>a[j+1])
             {
               temp=a[j];
               a[j]=a[j+1];
               a[j+1]=temp;
             }   
          }
       }
       for(int i=0;i<n;i++)
       {
           cout<<a[i];
       }
           cout<<endl;
       return 0;
    }
    #include<iostream>
    
    using namespace std;
    
    
    int shortTest(int c,char * v)
    {
       int i,j,temp;
       
       for(i=0;i<c;i++)
       {
          for(j=i+1;j<c;j++)
          {
             if(*(v+i)>=*(v+j))
             {
                 temp=*(v+i);
                 *(v+i)=*(v+j);
                 *(v+j)=temp;
             }
          }
       }
       return 0;
    };
    
  • 相关阅读:
    申请加分项
    课程评价
    本周总结
    热词2
    热词1
    php大作业
    css网格布局
    php实验4
    本周总结
    css边框图像
  • 原文地址:https://www.cnblogs.com/heling/p/4114908.html
Copyright © 2011-2022 走看看