結果
| 問題 | 
                            No.24 数当てゲーム
                             | 
                    
| コンテスト | |
| ユーザー | 
                             Hissha_
                         | 
                    
| 提出日時 | 2018-03-29 21:27:22 | 
| 言語 | C  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 2,156 bytes | 
| コンパイル時間 | 387 ms | 
| コンパイル使用メモリ | 30,080 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-06-25 23:52:31 | 
| 合計ジャッジ時間 | 809 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 2 WA * 8 | 
コンパイルメッセージ
main.c: In function 'cal':
main.c:39:25: warning: passing argument 1 of 'strcmp' from incompatible pointer type [-Wincompatible-pointer-types]
   39 |               if(strcmp(&h,&y)==0){
      |                         ^~
      |                         |
      |                         char (*)[3]
In file included from main.c:3:
/usr/include/string.h:156:32: note: expected 'const char *' but argument is of type 'char (*)[3]'
  156 | extern int strcmp (const char *__s1, const char *__s2)
      |                    ~~~~~~~~~~~~^~~~
main.c:39:28: warning: passing argument 2 of 'strcmp' from incompatible pointer type [-Wincompatible-pointer-types]
   39 |               if(strcmp(&h,&y)==0){
      |                            ^~
      |                            |
      |                            char (*)[3]
/usr/include/string.h:156:50: note: expected 'const char *' but argument is of type 'char (*)[3]'
  156 | extern int strcmp (const char *__s1, const char *__s2)
      |                                      ~~~~~~~~~~~~^~~~
main.c:61:25: warning: passing argument 1 of 'strcmp' from incompatible pointer type [-Wincompatible-pointer-types]
   61 |               if(strcmp(&h,&n)==0){
      |                         ^~
      |                         |
      |                         char (*)[3]
/usr/include/string.h:156:32: note: expected 'const char *' but argument is of type 'char (*)[3]'
  156 | extern int strcmp (const char *__s1, const char *__s2)
      |                    ~~~~~~~~~~~~^~~~
main.c:61:28: warning: passing argument 2 of 'strcmp' from incompatible pointer type [-Wincompatible-pointer-types]
   61 |               if(strcmp(&h,&n)==0){
      |                            ^~
      |                            |
      |                            char (*)[3]
/usr/include/string.h:156:50: note: expected 'const char *' but argument is of type 'char (*)[3]'
  156 | extern int strcmp (const char *__s1, const char *__s2)
      |                              
            
            ソースコード
#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;
}
            
            
            
        
            
Hissha_