1 solutions

  • 0
    @ 2025-3-3 16:27:12

    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;
    }
    
    • 1

    Information

    ID
    10138
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    (None)
    Tags
    # Submissions
    0
    Accepted
    0
    Uploaded By