c++编程 冒泡排序
#include<iostream>
using namespace std;
void maopao(int a[],int size)
{int temp,work;
for(int pass=1;pass<size;pass++)
{work=1;
for(int i=0;i<size-pass;i++)
{if(a[i]>a[i+1])
{temp=a[i];
a[i]=a[i+1];
a[i+1]=temp;
work=0;
}}if(work) break;
}}int main()
{int a[100],i,size;
size=0;
for(i=0;;i++)
{cin>>a[i];
if(a[i]==0) break;
size++;
}maopao(a,size);
for(int i=0;i<size;i++)
cout<<a[i]<<" ";
}
using namespace std;
void maopao(int a[],int size)
{int temp,work;
for(int pass=1;pass<size;pass++)
{work=1;
for(int i=0;i<size-pass;i++)
{if(a[i]>a[i+1])
{temp=a[i];
a[i]=a[i+1];
a[i+1]=temp;
work=0;
}}if(work) break;
}}int main()
{int a[100],i,size;
size=0;
for(i=0;;i++)
{cin>>a[i];
if(a[i]==0) break;
size++;
}maopao(a,size);
for(int i=0;i<size;i++)
cout<<a[i]<<" ";
}
Last one:数字练习
Next one:英文265
声明:以上文章均为用户自行添加,仅供打字交流使用,不代表本站观点,本站不承担任何法律责任,特此声明!如果有侵犯到您的权利,请及时联系我们删除。
Hot degree:★☆☆☆☆
Difficulty:☆☆☆☆☆
quality:☆☆☆☆☆
Description: the system according to the heat, the difficulty, the quality of automatic certification, the certification of the article will be involved in typing!
This paper typing ranking TOP20
登录后可见