結果

問題 No.69 文字を自由に並び替え
コンテスト
ユーザー spacenaut
提出日時 2016-05-12 21:34:50
言語 C90
(gcc 12.4.0)
コンパイル:
gcc-12 -O2 -std=c90 -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 541 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 193 ms
コンパイル使用メモリ 29,508 KB
最終ジャッジ日時 2026-02-23 21:16:33
ジャッジサーバーID
(参考情報)
judge5 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 13 RE * 2
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:9:19: warning: incompatible implicit declaration of built-in function ‘strlen’ [-Wbuiltin-declaration-mismatch]
    9 |         int len = strlen(a);
      |                   ^~~~~~
main.c:2:1: note: include ‘<string.h>’ or provide a declaration of ‘strlen’
    1 | #include <stdio.h>
  +++ |+#include <string.h>
    2 | 
main.c:8:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 |         scanf("%s%s", a, b);
      |         ^~~~~~~~~~~~~~~~~~~

ソースコード

diff #
raw source code

#include <stdio.h>

int main(void){
	char a[10];
	char b[10];
	char temp;
	int i, j;
	scanf("%s%s", a, b);
	int len = strlen(a);
	
	for(i = 0; i < len - 1; i++){
		for(j = 0; j < len - 1 - i; j++){
			if(a[j] > a[j + 1]){
				temp = a[j];
				a[j] = a[j + 1];
				a[j + 1] = temp;
			}
		}
	}
	for(i = 0; i < len - 1; i++){
		for(j = 0; j < len - 1 - i; j++){
			if(b[j] > b[j + 1]){
				temp = b[j];
				b[j] = b[j + 1];
				b[j + 1] = temp;
			}
		}
	}
	if(strcmp(a, b) == 0){
		printf("YES\n");
	}else{
		printf("NO\n");
	}
	
	return 0;
}
0