結果

問題 No.267 トランプソート
ユーザー FF256grhyFF256grhy
提出日時 2015-08-21 22:50:53
言語 C++11
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 1,143 bytes
コンパイル時間 256 ms
コンパイル使用メモリ 23,680 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-18 11:51:39
合計ジャッジ時間 777 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 3
other WA * 20
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:50:42: warning: format ‘%c’ expects argument of type ‘int’, but argument 2 has type ‘const char*’ [-Wformat=]
   50 |                                 printf("%c%c%c", (flag ? " " : ""), c1, c2);
      |                                         ~^       ~~~~~~~~~~~~~~~~~
      |                                          |             |
      |                                          int           const char*
      |                                         %s
main.cpp:7:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    7 |         scanf("%d", &n);
      |         ~~~~~^~~~~~~~~~
main.cpp:11:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 |                 scanf("%c%c%c", &cx, &c1, &c2);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:29:34: warning: ‘m1’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   29 |                 memo[m1][m2 - 1] = 1;
      |                 ~~~~~~~~~~~~~~~~~^~~

ソースコード

diff #

#include <stdio.h>

int n, memo[4][13];
char c1, c2, cx;

int main(void) {
	scanf("%d", &n);
	
	int i, j;
	for(i = 0; i < n; i++) {
		scanf("%c%c%c", &cx, &c1, &c2);
		printf("  test  : %c%c \n", c1, c2);
		int m1, m2;
		switch(c1) {
			case 'D': m1 = 0; break;
			case 'C': m1 = 1; break;
			case 'H': m1 = 2; break;
			case 'S': m1 = 3; break;
		}
		switch(c2) {
			case 'A': m2 =  1; break;
			case 'T': m2 = 10; break;
			case 'J': m2 = 11; break;
			case 'Q': m2 = 12; break;
			case 'K': m2 = 13; break;
			default:  m2 = c1 - '0';
		}
		printf("  mmmm  : %d%d \n", m1, m2);
		memo[m1][m2 - 1] = 1;
	}
	
	int flag = 0;
	for(i = 0; i < 4; i++) {
		switch(i) {
			case 0: c1 = 'D'; break;
			case 1: c1 = 'C'; break;
			case 2: c1 = 'H'; break;
			case 3: c1 = 'S'; break;
		}
		for(j = 0; j < 13; j++) {
			if(memo[i][j]) {
				switch(j) {
					case  0: c2 = 'A'; break;
					case  9: c2 = 'T'; break;
					case 10: c2 = 'J'; break;
					case 11: c2 = 'Q'; break;
					case 12: c2 = 'K'; break;
					default: c2 = j + 1 + '0';
				}
				printf("%c%c%c", (flag ? " " : ""), c1, c2);
				flag = 1;
			}
		}
	}
	printf("\n");
	
	return 0;
}
0