#19174: answer


0972965333 (阿達)

學校 : 臺北市私立延平高級中學
編號 : 83255
來源 : [203.72.178.252]
最後登入時間 :
2020-07-01 17:09:01
a225. 明明愛排列 | From: [203.72.178.252] | 發表日期 : 2019-09-11 17:29

#include <iostream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char** argv) {
	int x,a[1001];
	string c;
	while(cin>>x)
	{
		
		for(int i=0;i<x;++i)
	    	cin>>a[i+1];
	    for(int i=0;i<=x;++i)
		{
			for(int i=2;i<=x;++i){
			
				int t=a[i];
				if(a[i]%10<a[i-1]%10 || a[i]%10==a[i-1]%10 && a[i-1]<a[i])
				{
					a[i]=a[i-1];
					a[i-1]=t;
					
				}
			}
		
		}
		for(int i=0;i<x;++i)
			cout<<a[i+1]<<" ";	
		cout<<endl;	
	}
	
	
	
	
	
	
	
	
	
}
Close
CPP

 

 
ZeroJudge Forum