結果

問題 No.26 シャッフルゲーム
ユーザー sasa
提出日時 2025-03-03 13:40:04
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
RE  
実行時間 -
コード長 780 bytes
コンパイル時間 305 ms
コンパイル使用メモリ 29,824 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2025-03-03 13:40:07
合計ジャッジ時間 2,369 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other RE * 10
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:10:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   10 |         scanf("%d",&loc);
      |         ~~~~~^~~~~~~~~~~
main.cpp:19:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   19 |         scanf("%d",&count);
      |         ~~~~~^~~~~~~~~~~~~
main.cpp:24:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   24 |                 scanf("%d",&rep1);
      |                 ~~~~~^~~~~~~~~~~~
main.cpp:26:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   26 |                 scanf("%d",&rep2);
      |                 ~~~~~^~~~~~~~~~~~

ソースコード

diff #

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

int main(void){
	// カップの個数
	int *judgment[3] = {0,0,0};
	// 初めに〇がついてるカップの位置
	int loc = 0;
	scanf("%d",&loc);
	// 〇の位置を配列に格納
	for(int i = 0;i < 3;i++){
		if(i == (loc - 1)){
			*judgment[i] = 1;
		}
	}
	// 入れ替える回数
	int count = 0;
	scanf("%d",&count);
	
	int i = 0;
	while(i != count){
		int rep1 = 0;
		scanf("%d",&rep1);
		int rep2 = 0;
		scanf("%d",&rep2);
		
		for(int i = 0;i < 3;i++){
			if(i == rep1){
				rep1 = *judgment[i];
			}else if(i == rep2){
				rep2 = *judgment[i];
			}
		}
		
		int tmp = 0;
		tmp = rep1;
		rep1 = rep2;
		rep2 = tmp;
		i++;
	}
	for(int i = 0;i < 3;i++){
		if(*judgment[i] == 1){
			printf("%d",i + 1);
		}
	}
}
0