#42525: 請大佬幫幫忙(無法輸出最後一行)


yp11251234@yphs.tp.edu.tw (908-35 許令橋)

學校 : 臺北市私立延平高級中學
編號 : 239200
來源 : [203.72.178.2]
最後登入時間 :
2025-10-08 16:38:52

#include<bits/stdc++.h>
using namespace std;
int main(){
    string order;
    int kill,assist,die,combo,hkill,hdie,n;
    while(cin>>n){
    kill=assist=die=combo=0;
    while(cin>>order){
    if(order=="Get_Kill"){
    combo++;
        kill++;
        hkill++;
if(combo==3) cout<<"KILLING SPREE!"<<endl;
else if(combo==4) cout<<"RAMPAGE~"<<endl;
else if(combo==5) cout<<"UNSTOPPABLE!"<<endl;
else if(combo==6) cout<<"DOMINATING!"<<endl;
else if(combo==7) cout<<"GUALIKE!"<<endl;
else if(combo>=8) cout<<"LEGENDARY!"<<endl;
else if(kill>0 && combo<3) cout<<"You have slain an enemie."<<endl;
}
    else if(order=="Get_Assist"){
    assist++;
}
    else if(order=="Die"){
        die++;
        hdie++;
if(die>0 && combo<3) cout<<"You have been slained."<<endl;
else if(combo>=3) cout<<"SHUTDOWN."<<endl;
kill=combo=0;
        }
}  
}
cout<<hkill<<"/"<<hdie<<"/"<<assist<<endl;
}
#42527: Re: 請大佬幫幫忙(無法輸出最後一行)


asnewchien@gmail.com (david)

學校 : 南投縣立旭光高級中學
編號 : 68108
來源 : [114.42.176.221]
最後登入時間 :
2025-10-04 22:52:03

hkill 的初值.

#42528: Re: 請大佬幫幫忙(無法輸出最後一行)


yp11251234@yphs.tp.edu.tw (908-35 許令橋)

學校 : 臺北市私立延平高級中學
編號 : 239200
來源 : [203.72.178.2]
最後登入時間 :
2025-10-08 16:38:52

hkill 的初值.


感謝~~~

#42538: Re: 請大佬幫幫忙(無法輸出最後一行)


yp11251234@yphs.tp.edu.tw (908-35 許令橋)

學校 : 臺北市私立延平高級中學
編號 : 239200
來源 : [203.72.178.2]
最後登入時間 :
2025-10-08 16:38:52

hkill 的初值.


感謝~~~


正解(修了一些變數名稱&加for)

#include<bits/stdc++.h>
using namespace std;
int main(){
    string order;
    int kill,assist,die,combo,totalKill=0,totalDeath=0,n;
    while(cin>>n){
        kill=assist=die=combo=0;
        for(int i=0;i<n;i++){
            cin>>order;
            if(order=="Get_Kill"){
                combo++;
                kill++;
                totalKill++;
                if (combo==3) cout <<"KILLING SPREE!"<<endl;
                else if (combo==4) cout <<"RAMPAGE~"<<endl;
                else if (combo==5) cout <<"UNSTOPPABLE!"<<endl;
                else if (combo==6) cout <<"DOMINATING!"<<endl;
                else if (combo==7) cout <<"GUALIKE!"<<endl;
                else if (combo>=8) cout <<"LEGENDARY!"<<endl;
                else if (kill>0 && combo<3) cout<<"You have slain an enemie."<<endl;
            } else if(order=="Get_Assist"){
                assist++;
            } else if(order=="Die") {
                die++;
                totalDeath++;
                if (die>0 && combo<3) cout<<"You have been slained."<<endl;
                else if(combo>=3) cout<<"SHUTDOWN."<<endl;
                kill=combo=0;
            }
        }
        cout<<totalKill<<"/"<<totalDeath<<"/"<<assist<<endl;
    }
}