結果

問題 No.69 文字を自由に並び替え
ユーザー mamo_ICE
提出日時 2022-12-19 19:43:16
言語 C
(gcc 13.3.0)
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 526 bytes
コンパイル時間 1,471 ms
コンパイル使用メモリ 27,648 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-18 01:15:12
合計ジャッジ時間 1,202 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 15
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function 'main':
main.c:7:5: warning: implicit declaration of function 'gets'; did you mean 'fgets'? [-Wimplicit-function-declaration]
    7 |     gets(str1);
      |     ^~~~
      |     fgets
/usr/bin/ld: /tmp/ccwKg02z.o: in function `main':
main.c:(.text.startup+0x16): 警告: the `gets' function is dangerous and should not be used.

ソースコード

diff #

#include <stdio.h>

int main(void){
    int i, j;
    char str1[11], str2[11], tmp, ans = 1;
    
    gets(str1);
    gets(str2);
    for(i=0; str1[i]; i++){
        for(j=i; str2[j]; j++){
            if(str1[i] == str2[j]){
                tmp = str2[i];
                str2[i] = str2[j];
                str2[j] = tmp;
                break;
            }
        }
        if(str2[j] == '\0'){
            ans = 0;
            break;
        }
    }
    
    if(ans) puts("YES");
    else puts("NO");
    
    return 0;
}
0