#include<iostream>
using namespace std;
int main()
{
int a[8] = {43,18,39,35,17,20,33,34};
int temp,j;
for(int i = 1;i <= 7; i++)
{
temp = a[i];
j = i-1;
while(j>=0&&a[j]>temp)
{
a[j+1]=a[j];
--j;
}
a[j+1] = temp; //开始编的时候写错了这句所以结果出错
}
for(int i = 0;i < 8; i++)
{
cout<<a[i]<<endl;
}
system("pause");
return 0;
}
using namespace std;
int main()
{
int a[8] = {43,18,39,35,17,20,33,34};
int temp,j;
for(int i = 1;i <= 7; i++)
{
temp = a[i];
j = i-1;
while(j>=0&&a[j]>temp)
{
a[j+1]=a[j];
--j;
}
a[j+1] = temp; //开始编的时候写错了这句所以结果出错
}
for(int i = 0;i < 8; i++)
{
cout<<a[i]<<endl;
}
system("pause");
return 0;
}
1620

被折叠的 条评论
为什么被折叠?



