結果

問題 No.201 yukicoderじゃんけん
ユーザー カルロス
提出日時 2015-09-16 10:48:36
言語 C90
(gcc 12.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 652 bytes
コンパイル時間 122 ms
コンパイル使用メモリ 21,248 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-19 06:40:55
合計ジャッジ時間 740 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:6:13: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘char (*)[100]’ [-Wformat=]
    6 |     scanf("%s %s %c %s %s %c", &SA, &PA, &XA, &SB, &PB, &XB);
      |            ~^                  ~~~
      |             |                  |
      |             char *             char (*)[100]
main.c:6:16: warning: format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘char (*)[100000]’ [-Wformat=]
    6 |     scanf("%s %s %c %s %s %c", &SA, &PA, &XA, &SB, &PB, &XB);
      |               ~^                    ~~~
      |                |                    |
      |                char *               char (*)[100000]
main.c:6:22: warning: format ‘%s’ expects argument of type ‘char *’, but argument 5 has type ‘char (*)[100]’ [-Wformat=]
    6 |     scanf("%s %s %c %s %s %c", &SA, &PA, &XA, &SB, &PB, &XB);
      |                     ~^                        ~~~
      |                      |                        |
      |                      char *                   char (*)[100]
main.c:6:25: warning: format ‘%s’ expects argument of type ‘char *’, but argument 6 has type ‘char (*)[100000]’ [-Wformat=]
    6 |     scanf("%s %s %c %s %s %c", &SA, &PA, &XA, &SB, &PB, &XB);
      |                        ~^                          ~~~
      |                         |                          |
      |                         char *                     char (*)[100000]
main.c:6:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    6 |     scanf("%s %s %c %s %s %c", &SA, &PA, &XA, &SB, &PB, &XB);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

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

int main(void){
    char SA[100], SB[100], PA[100000], PB[100000], XA, XB;
    scanf("%s %s %c %s %s %c", &SA, &PA, &XA, &SB, &PB, &XB);
    int a = strlen(PA), b = strlen(PB);
    int i = 0;
    if(a>b){
        printf("%s\n", SA);
    }else if(a<b){
        printf("%s\n", SB);
    }else{
        while(i<=a){
            if(strcmp(&PA[i], &PB[i])>0){
                printf("%s\n", SA);
                return 0;
            }else if(strcmp(&PA[i], &PB[i])<0){
                printf("%s\n", SB);
                return 0;
            }
            i++;
        }
        printf("-1\n");
    }
    return 0;
}
0