結果

問題 No.69 文字を自由に並び替え
ユーザー Elk
提出日時 2018-05-26 15:14:51
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 601 bytes
コンパイル時間 771 ms
コンパイル使用メモリ 23,296 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-14 07:04:10
合計ジャッジ時間 889 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 15
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:8:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 |     scanf("%s%s", str1, str2);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

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

int main(){
    char str1[11], str2[11];
    int i, j, len, cnt = 0, flag[10] = {0};

    scanf("%s%s", str1, str2);
    len = strlen(str1);

    for(i = 0; i < len; i++){
        for(j = 0; j < len; j++){
            if(str1[i] == str2[j] && flag[j] == 0){
                flag[j] = 1;
                //printf("i %d j %d\n", i, j);
                break;
            }
        }
    }
    for(i = 0; i < len; i++){
        if(flag[i] == 1)    cnt++;
    }
    if(cnt == len){
        printf("YES\n");
    }else{
        printf("NO\n");
    }

    return 0;
}
0