結果
| 問題 | 
                            No.267 トランプソート
                             | 
                    
| コンテスト | |
| ユーザー | 
                             184
                         | 
                    
| 提出日時 | 2015-08-25 13:48:57 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 2 ms / 1,000 ms | 
| コード長 | 919 bytes | 
| コンパイル時間 | 625 ms | 
| コンパイル使用メモリ | 61,672 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-07-18 13:20:52 | 
| 合計ジャッジ時間 | 1,427 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 20 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:10:20: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   10 |         int n;scanf("%d",&n);
      |               ~~~~~^~~~~~~~~
main.cpp:13:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   13 |                 scanf("%s",s);
      |                 ~~~~~^~~~~~~~
            
            ソースコード
#include <cstdio> 
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main(){
	int n;scanf("%d",&n);
	vector<string> v;char s[5];
	for(int i=0;i<n;i++){
		scanf("%s",s);
		if(s[0]=='D')s[0]=1;
		else if(s[0]=='C')s[0]=2;
		else if(s[0]=='H')s[0]=3;
		else if(s[0]=='S')s[0]=4;
		if(s[1]=='A'){s[1]='1';}
		else if(s[1]=='T')s[1]='9'+1;
		else if(s[1]=='J')s[1]='9'+2;
		else if(s[1]=='Q')s[1]='9'+3;
		else if(s[1]=='K')s[1]='9'+4;
		v.push_back(s);
	}
	
	sort(v.begin(),v.end());
	
	for(int i=0;i<v.size();i++){
		if(v[i][0]==1)v[i][0]='D';
		else if(v[i][0]==2)v[i][0]='C';
		else if(v[i][0]==3)v[i][0]='H';
		else if(v[i][0]==4)v[i][0]='S';
		if(v[i][1]=='1'){v[i][1]='A';}
		else if(v[i][1]=='9'+1)v[i][1]='T';
		else if(v[i][1]=='9'+2)v[i][1]='J';
		else if(v[i][1]=='9'+3)v[i][1]='Q';
		else if(v[i][1]=='9'+4)v[i][1]='K';
		printf("%s ",v[i].c_str());
	}
	puts("");
	return 0;
}
            
            
            
        
            
184