1 solutions
-
0
C++ :
#include <bits/stdc++.h> using namespace std; string s[1005]; int n; int main(){ while(cin>>s[n]) { if(s[n]=="end")break; n++; } string t; for(int i=0;i<n;i++) for(int j=n-1;j>i;j--) if(s[j]<s[j-1]) { t=s[j]; s[j]=s[j-1]; s[j-1]=t; } for(int i=0;i<n;i++) cout<<s[i]<<endl; return 0; }Pascal :
var n,i,j:integer; st:array[1..100] of string; bl:string; begin n:=0; repeat inc(n); readln(st[n]); until st[n]='end'; for i:=1 to n-1 do for j:=i+1 to n-1 do if st[i]>st[j] then begin bl:=st[i]; st[i]:=st[j]; st[j]:=bl; end; for i:=1 to n-1 do writeln(st[i]); end.
- 1
Information
- ID
- 16618
- Time
- 1000ms
- Memory
- 128MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By