結果

問題 No.24 数当てゲーム
ユーザー Hissha_Hissha_
提出日時 2018-03-29 21:37:02
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 2,156 bytes
コンパイル時間 222 ms
コンパイル使用メモリ 29,252 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-09-08 06:38:40
合計ジャッジ時間 786 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 0 ms
4,376 KB
testcase_08 WA -
testcase_09 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: 関数 ‘cal’ 内:
main.c:39:25: 警告: 互換性のないポインタ型から 1 番目の ‘strcmp’ の引数に渡しています [-Wincompatible-pointer-types]
   39 |               if(strcmp(&h,&y)==0){
      |                         ^~
      |                         |
      |                         char (*)[3]
次のファイルから読み込み:  main.c:3:
/usr/include/string.h:137:32: 備考: expected ‘const char *’ but argument is of type ‘char (*)[3]’
  137 | extern int strcmp (const char *__s1, const char *__s2)
      |                    ~~~~~~~~~~~~^~~~
main.c:39:28: 警告: 互換性のないポインタ型から 2 番目の ‘strcmp’ の引数に渡しています [-Wincompatible-pointer-types]
   39 |               if(strcmp(&h,&y)==0){
      |                            ^~
      |                            |
      |                            char (*)[3]
/usr/include/string.h:137:50: 備考: expected ‘const char *’ but argument is of type ‘char (*)[3]’
  137 | extern int strcmp (const char *__s1, const char *__s2)
      |                                      ~~~~~~~~~~~~^~~~
main.c:61:25: 警告: 互換性のないポインタ型から 1 番目の ‘strcmp’ の引数に渡しています [-Wincompatible-pointer-types]
   61 |               if(strcmp(&h,&n)==0){
      |                         ^~
      |                         |
      |                         char (*)[3]
/usr/include/string.h:137:32: 備考: expected ‘const char *’ but argument is of type ‘char (*)[3]’
  137 | extern int strcmp (const char *__s1, const char *__s2)
      |                    ~~~~~~~~~~~~^~~~
main.c:61:28: 警告: 互換性のないポインタ型から 2 番目の ‘strcmp’ の引数に渡しています [-Wincompatible-pointer-types]
   61 |               if(strcmp(&h,&n)==0){
      |                            ^~
      |                            |
      |                            char (*)[3]
/usr/include/str

ソースコード

diff #

#include <stdio.h>

#include<string.h>

 

struct say{

              int card0;

              int card1;

              int card2;

              int card3;

              char hantei[3];

};

 

void cal(int hav[], struct say *answer){

              int i, j, count=0;

              char y[3], n[3], h[3];

             

              strcpy(y,"YES");

              strcpy(n,"NO");

              strcpy(h,answer->hantei);

             

              if(strcmp(&h,&y)==0){

                            for(i=0;i<10;i++){

                                          if(i==answer->card0) count+=1;

                                          if(i==answer->card1) count+=1;

                                          if(i==answer->card2) count+=1;

                                          if(i==answer->card3) count+=1;

                                          if(count==0) hav[i]=0;

                                          count=0;

                            }

              }

             

              if(strcmp(&h,&n)==0){

                            for(i=0;i<10;i++){

                                          if(i==answer->card0) count+=1;

                                          if(i==answer->card1) count+=1;

                                          if(i==answer->card2) count+=1;

                                          if(i==answer->card3) count+=1;

                                          if(count!=0) hav[i]=0;

                                          count=0;

                            }

              }

             

}

 

int main(void) {

              // your code goes here

              int turn, i, j;

              int have[10]={1,1,1,1,1,1,1,1,1,1};

              struct say taro;

 

              scanf("%d", &turn);

 

              for(i=0;i<turn;i++){

                        scanf("%d %d %d %d %s", &taro.card0, &taro.card1, &taro.card2, &taro.card3, taro.hantei);

                        cal(have, &taro);

              }

             

              for(j=0;j<10;j++){

                            if(have[j]==1) printf("%d\n",j);

              }

 

              return 0;

}
0