c++分行输入abcd,从小到大分行输出abcd怎么写程序

注意是输出abcd

第1个回答  2014-03-30
string rr = "从小到大排序\n";
var dd = Console.ReadLine().Split(" "[0]);
Int16[] bb = new Int16[dd.Length]; Int16 cc = 0;
foreach (var ee in Enumerable.Range(0, dd.Length))
{
foreach (string aa in dd)
{
if (!rr.Contains(aa)) if (!bb.Contains(Int16.Parse(aa)))
{
if (cc == 0)
cc = Int16.Parse(aa);
if (cc > Int16.Parse(aa))
cc = Int16.Parse(aa);
}
}
rr = rr.Insert(rr.Length, cc + "\n");
bb[ee] = cc;
cc = 0;
}
Console.WriteLine(rr);
Console.WriteLine(string.Join("\n", bb));
c#参考
第2个回答  2014-03-30
#include "StdAfx.h"
#include<iostream>
using namespace std;
 
int main()
{
    int list[4];
 
    cout<<"请输入待排序的整数数列:"<<endl;
 
    for(int  i=0; i<4; i++)
    {
        cin>>list[i];
    }
int j=0;
while (j<3)
{
if(list[j]>list[j+1])
{
int tmp=list[j];
list[j]=list[j+1];
list[j+1]=tmp;
j=0;
}
else j++;

}
    cout<<"排序后的整数序列是:";
 
    for (i = 0; i < 4; i++)
    {
        cout << list[i]<<endl;
    }
    system("pause");
    return 0;
}

追问

list是什么意思?

追答

list 数组名 “list[1]”表示是数组第一位

本回答被提问者和网友采纳
第3个回答  2014-03-30
这太简单了
相似回答