結果

問題 No.69 文字を自由に並び替え
ユーザー pracodepracode
提出日時 2018-09-19 18:12:13
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 704 bytes
コンパイル時間 180 ms
コンパイル使用メモリ 28,712 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-21 00:08:42
合計ジャッジ時間 945 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 0 ms
4,376 KB
testcase_02 AC 0 ms
4,380 KB
testcase_03 AC 0 ms
4,384 KB
testcase_04 AC 0 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,384 KB
testcase_14 AC 0 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <string.h>

void swap(char *c1, char*c2);
void alphasort(char str[], int count);

int main()
{
	char str1[11];
	char str2[11];
	int ans;
	int count = 0;

	scanf("%s", str1);
	scanf("%s", str2);

	while (str1[count]!= '\0') {
		count++;
	}


	alphasort(str1,count);
	alphasort(str2,count);
	
	ans = strcmp(str1, str2);
	printf("%s\n", (ans == 0 ? "YES" : "NO"));
	return 0;
}

void swap(char *c1,char *c2)
{
	char temp;

	temp = *c1;
	*c1 = *c2;
	*c2 = temp;
}

void alphasort(char str[], int count)
{
	int i, j;

	for (i = 0; i < count - 1; i++) {
		for (j = 0; j < count - 1- i; j++) {
			if ((int)(str[j]) >= (int)(str[j + 1])){
				swap(&str[j], &str[j + 1]);
			}
		}
	}
}
0