View Code of Problem 78

#include<bits/stdc++.h>
using namespace std;
int Equ(char c1[], char c2[]) {
	int t1=0,t2=0;
	while(t1<strlen(c1)&&t2<strlen(c2)) {
		if(c1[t1]==c2[t2]) {
			t1++;
			t2++;
		}else if(c1[t1]>c2[t2]) return 1;
		else return 2;
	}
	if(strlen(c1)>strlen(c2)) return 1;
	else if(strlen(c1)<strlen(c2)) return 2;
	else return 0;
}
int main() {
	char c[3][1000],t[1000];
	for(int i=0; i<3; i++) cin>>c[i];
	for(int i=0; i<2; i++) {
		for(int j=1; j<3; j++) {
			if(Equ(c[i],c[j])==1) {//交换 
				strcpy(t,c[i]);
				strcpy(c[i],c[j]);
				strcpy(c[j],t);
			}
		}
	}
	for(int i=0; i<3; i++) cout<<c[i]<<endl;
}

Double click to view unformatted code.


Back to problem 78