#16794: 求解測試都沒問題 可是送出一直顯示這個


ben31908@gmail.com (ANAlyst)

學校 : 國立桃園高級中學
編號 : 68409
來源 : [1.173.204.92]
最後登入時間 :
2022-12-10 16:13:14
b964. 1. 成績指標 -- 2016年3月apcs | From: [36.229.183.90] | 發表日期 : 2019-02-07 20:54

#0: 100% WA (line:1)

您的答案為: 28 
正確答案為: 28

這個是錯在哪裡?



程式碼:

#include<iostream>
#include<algorithm>
using namespace std;

int main(){
int size;
while(cin>>size){
int *score = new int[size];
for(int i=0;i<size;i++)cin>>score[i];
sort(score,score+size);
for(int i=0;i<size;i++)cout<<score[i]<<' ';
cout<<endl;
if(score[0]>=60)cout<<"best case"<<endl;
else{
int i=size-1;
while(score[i]>=60)i--;
cout<<score[i]<<endl;
};
if(score[size-1]<60)cout<<"worst case"<<endl;
else{
int i=0;
while(score[i]<60)i++;
cout<<score[i]<<endl;
}
delete[] score;
}
return 0;
}
 
#16795: Re:求解測試都沒問題 可是送出一直顯示這個


314159265358979323846264338327 ... (少年π)

學校 : 臺北市私立延平高級中學
編號 : 69058
來源 : [223.137.74.225]
最後登入時間 :
2024-04-18 19:26:56
b964. 1. 成績指標 -- 2016年3月apcs | From: [223.136.46.9] | 發表日期 : 2019-02-07 21:09

#0: 100% WA (line:1)

您的答案為: 28 
正確答案為: 28

這個是錯在哪裡?



程式碼:

#include
#include
using namespace std;

int main(){
int size;
while(cin>>size){
int *score = new int[size];
for(int i=0;i<size;i++)cin>>score[i];
sort(score,score+size);
for(int i=0;i<size;i++)cout<<score[i]<<' ';
cout<<endl;
if(score[0]>=60)cout<<"best case"<<endl;
else{
int i=size-1;
while(score[i]>=60)i--;
cout<<score[i]<<endl;
};
if(score[size-1]<60)cout<<"worst case"<<endl;
else{
int i=0;
while(score[i]<60)i++;
cout<<score[i]<<endl;
}
delete[] score;
}
return 0;
}

換行前的最後一個不能輸出空格


 
#16823: Re:求解測試都沒問題 可是送出一直顯示這個


hslin001@gmail.com (HONGHSIN LIN)

學校 : 國立溪湖高級中學
編號 : 82904
來源 : [114.42.192.49]
最後登入時間 :
2022-08-06 17:50:30
b964. 1. 成績指標 -- 2016年3月apcs | From: [1.170.212.241] | 發表日期 : 2019-02-10 16:54

我也是一樣,出現上面的訊息,求解

while True:

    try:

        n = eval(input())

        x=[]

        x = input().strip()

        x=x.split(' ')

 

        for j in range(len(x)):

            x[j] = int(x[j])

 

        x.sort()

        

        w = True

        b = True

        for j in x:

             if j < 60:

                b = False

            if j >= 60:

                w = False

            print(j,'',end='')

        print(end='\n')

 

       

        t = []

        if b == False:

            for j in x:

                if j < 60:

                    t.append(j)

            #print(t)

            print(t[len(t)-1])   

 

        else:

                print('best case')

        p=[]

        if w == False:

            for j in x:

               if j >= 60:

                    p.append(j)

            print(p[0])

        else:

                print('worst case')

            

    except:

        break

 

 
 
ZeroJudge Forum