求助,在DEV上测的是对的,到洛谷上就错了
查看原帖
求助,在DEV上测的是对的,到洛谷上就错了
368091
chengbohan楼主2021/10/21 22:06
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
using namespace std;
int read(){
	int s=0;int k=1;char c=getchar ();
	while (!isdigit (c)) {if (c=='-') k=-1;c=getchar ();}
	while (isdigit (c)) {s=s*10+c-'0';c=getchar ();}
	return s*k;
}
struct node{
	char s[22];
}a[22];
bool cmp(node p,node q){
	int t=strcmp(p.s+1,q.s+1);
	if (t==1){
		return true;
	}
	return false;
}
int main(){
	int n;
	scanf("%d",&n);
	for (int i=1;i<=n;i++){
		scanf("%s",a[i].s+1);
	}
	sort(a+1,a+1+n,cmp);
	for (int i=1;i<=n;i++){
		int n=strlen(a[i].s+1);
		for (int j=1;j<=n;j++){
			printf("%c",a[i].s[j]);
		}
	}
	printf("\n");
	return 0;
}

in:

4

13 24 75 42

out:

75422413

求助大佬

2021/10/21 22:06
加载中...