結果
問題 | No.267 トランプソート |
ユーザー |
![]() |
提出日時 | 2015-08-21 22:58:58 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 1,000 ms |
コード長 | 1,065 bytes |
コンパイル時間 | 187 ms |
コンパイル使用メモリ | 22,784 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-18 11:56:09 |
合計ジャッジ時間 | 910 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: 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:27:34: warning: ‘m1’ may be used uninitialized in this function [-Wmaybe-uninitialized] 27 | memo[m1][m2 - 1] = 1; | ~~~~~~~~~~~~~~~~~^~~
ソースコード
#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);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 = c2 - '0';}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("%s%c%c", (flag ? " " : ""), c1, c2);flag = 1;}}}printf("\n");return 0;}