您的位置:首页 > 其它

CodeForces 12B - Correct Solution?

2015-09-17 19:17 225 查看
我想到的是把输入输出看作是字符串,然后用sort排序,当排序后,若第一个字符为‘0’,则在后面找到第一个非零的数,然后把它交换下就行了!总的来说这道题目应该比较简单的啦
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
int main()
{
char str[10];
char str1[10];
scanf("%s%s",str,str1);
int lenth=strlen(str);
sort(str,str+lenth);
int i=1;
while(str[0]=='0'&&lenth!=1)
{
swap(str[0],str[i]);
i++;
}
if(strcmp(str,str1)==0)
printf("OK\n");
else
printf("WRONG_ANSWER\n");
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: