標題:
607 撲克牌比大小
[打印本頁]
作者:
陳曜誌
時間:
2024-9-19 13:11
標題:
607 撲克牌比大小
1. 題目說明:
請依下列題意進行作答,使輸出值符合題意要求。
2. 設計說明:
請撰寫一程式,製作撲克牌比大小遊戲,讓使用者輸入兩張牌,比較兩張牌的大小並將結果輸出。
撲克牌比大小規則:每張牌分別以英文及數字表示,其中S代表黑桃、H代表紅心、D代表方塊、C代表梅花,數字為1~13。首先比較花色:黑桃>紅心>方塊>梅花;當花色相同時,再比較數字:13最大、1最小。
提示:數字「0」的ASCII碼=48。
提示:若使用 Java 語言答題,請以「JP」開頭命名包含 main 靜態方法的 class,評測系統才能正確評分。
3. 輸入輸出:
輸入說明
兩張撲克牌,以英文(S、H、D、C)及數字(1~13)表示
輸出說明
兩張撲克牌比大小結果
範例輸入1
S1 D13
範例輸出1
S1 > D13
範例輸入2
C5 C5
範例輸出2
C5 = C5
本帖隱藏的內容需要回復才可以瀏覽
作者:
何權晉
時間:
2024-9-20 20:11
#include<bits/stdc++.h>
using namespace std;
int main()
{
string s1,s2;
cin>>s1>>s2;
if(s1[0]>s2[0])
cout<<s1<<" > "<<s2;
else if(s1[0]<s2[0])
cout<<s1<<" < "<<s2;
else
{
int i1=stoi(s1.substr(1));
int i2=stoi(s2.substr(1));
if(i1<i2)
cout<<s1<<" < "<<s2;
else if(i1>i2)
cout<<s1<<" > "<<s2;
else
cout<<s1<<" = "<<s2;
}
return 0;
}
複製代碼
作者:
聿均
時間:
2024-9-20 20:13
#include <bits/stdc++.h>
using namespace std;
int main()
{
string s1,s2;
cin>>s1>>s2;
if(s1[0]>s2[0])
cout<<s1<<" > "<<s2;
else if(s1[0]<s2[0])
cout<<s1<<" < "<<s2;
else{
int i1=stoi(s1.substr(1));
int i2=stoi(s2.substr(1));
if(i1>i2)
cout<<s1<<" > "<<s2;
else if(i1<i2)
cout<<s1<<" < "<<s2;
else
cout<<s1<<" = "<<s2;
}
return 0;
}
複製代碼
作者:
黃翊豪
時間:
2024-9-20 20:13
#include<bits/stdc++.h>
using namespace std;
int main()
{
string s1,s2;
cin>>s1>>s2;
if(s1[0]>s2[0])
cout<<s1<<" > "<<s2;
else if(s1[0]<s2[0])
cout<<s1<<" < "<<s2;
else
{
int i1=stoi(s1.substr(1));
int i2=stoi(s2.substr(1));
if(i1<i2)
cout<<s1<<" < "<<s2;
else if(i1>i2)
cout<<s1<<" > "<<s2;
else
cout<<s1<<" = "<<s2;
}
}
複製代碼
作者:
吳侑諶
時間:
2024-9-20 20:15
#include <bits/stdc++.h>
using namespace std;
int main()
{
string s1,s2;
cin>>s1>>s2;
if(s1[0]>s2[0])
cout<<s1<<" > "<<s2;
else if(s1[0]<s2[0])
cout<<s1<<" < "<<s2;
else{
int i1=stoi(s1.substr(1));
int i2=stoi(s2.substr(1));
if(i1>i2)
cout<<s1<<" > "<<s2;
else if(i1<i2)
cout<<s1<<" < "<<s2;
else
cout<<s1<<" = "<<s2;
}
return 0;
}
複製代碼
作者:
蔡沛倢
時間:
2024-9-20 20:15
#include<bits/stdc++.h>
using namespace std;
string str1,str2;
int main()
{
cin>>str1>>str2;
if(str1[0]>str2[0])
{
cout<<str1<<" > "<<str2<<'\n';
}
else if(str1[0]<str2[0])
{
cout<<str1<<" < "<<str2<<'\n';
}
else
{
int i1=stoi(str1.substr(1));
int i2=stoi(str2.substr(1));
if(i1>i2)
{
cout<<str1<<" > "<<str2<<'\n';
}
else if(i1<i2)
{
cout<<str1<<" < "<<str2<<'\n';
}
else
{
cout<<str1<<" = "<<str2<<'\n';
}
}
return 0;
}
複製代碼
作者:
田家齊
時間:
2024-9-20 20:17
#include <bits/stdc++.h>
using namespace std;
string s1,s2;
int main()
{
cin>>s1>>s2;
if(s1[0]>s2[0])
{
cout<<s1<<" > "<<s2<<endl;
}else if(s1[0]<s2[0])
{
cout<<s1<<" < "<<s2<<endl;
}else
{
int i1=stoi(s1.substr(1));
int i2=stoi(s2.substr(1));
if(i1>i2)
{
cout<<s1<<" > "<<s2<<endl;
}else if(i1<i2)
{
cout<<s1<<" < "<<s2<<endl;
}else
{
cout<<s1<<" = "<<s2<<endl;
}
}
return 0;
}
複製代碼
作者:
郭又瑄
時間:
2024-9-26 18:29
#include<bits/stdc++.h>
using namespace std;
int main()
{
string s1,s2;
cin>>s1>>s2;
if(s1[0]>s2[0])
cout<<s1<<" > "<<s2;
else if(s1[0]<s2[0])
cout<<s1<<" < "<<s2;
else
{
int i1=stoi(s1.substr(1));
int i2=stoi(s2.substr(1));
if(i1<i2)
cout<<s1<<" < "<<s2;
else if(i1>i2)
cout<<s1<<" > "<<s2;
else
cout<<s1<<" = "<<s2;
}
return 0;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2