#29293: 這樣只有80% 有哪裡需要改強 才能到100%


0710ringe@gmail.com (白帥帥)

學校 : 不指定學校
編號 : 181772
來源 : [123.195.89.2]
最後登入時間 :
2022-06-21 20:51:13
b964. 1. 成績指標 -- 2016年3月apcs | From: [118.232.3.72] | 發表日期 : 2022-02-13 15:54

#include <iostream>

#include <algorithm>

using namespace std;

int main(){

int howmany,ALL,Q = 1,bs=0,ws; //幾筆資料 ,同,後面用到,bestcase,worsecase 

cin >> howmany ;

ALL = howmany;

int point[howmany];

while(howmany > 0){            //計算資料數 每完成一比-1 

cin >> point[howmany];     //in 

if(point[howmany] > 100 ){

point[howmany] = 100;

}

else if(point[howmany] < 0){

point[howmany] = 0;

}

howmany = howmany - 1;

}

sort(point, point + ALL+1);

ws = point[ALL];

 

while(ALL > 0){

cout << point[Q]<<" ";

if(point[Q] < 60){

point[Q] > bs;

bs = point[Q]; }

else{

if(point[Q] < ws){

ws = point[Q]; }

}

ALL = ALL - 1;

Q++;

}

if(bs == 0){

    cout<<endl<<"best case"<<endl; }

    else{

 

    cout <<endl<<bs<<endl;

}

 

    if(ws < 60){

    cout<<"worst case"; }

    else{

 

    cout << ws;

}

 

}

 

 
#29296: Re:這樣只有80% 有哪裡需要改強 才能到100%


cges30901 (cges30901)

學校 : 不指定學校
編號 : 30877
來源 : [101.136.203.77]
最後登入時間 :
2024-04-07 15:34:14
b964. 1. 成績指標 -- 2016年3月apcs | From: [27.52.135.20] | 發表日期 : 2022-02-13 17:14

#include

#include

using namespace std;

int main(){

int howmany,ALL,Q = 1,bs=0,ws; //幾筆資料 ,同,後面用到,bestcase,worsecase 

cin >> howmany ;

ALL = howmany;

int point[howmany];

while(howmany > 0){            //計算資料數 每完成一比-1 

cin >> point[howmany];     //in 

if(point[howmany] > 100 ){

point[howmany] = 100;

}

else if(point[howmany] < 0){

point[howmany] = 0;

}

howmany = howmany - 1;

}

sort(point, point + ALL+1);

ws = point[ALL];

 

while(ALL > 0){

cout << point[Q]<<" ";

if(point[Q] < 60){

point[Q] > bs;

bs = point[Q]; }

else{

if(point[Q] < ws){

ws = point[Q]; }

}

ALL = ALL - 1;

Q++;

}

if(bs == 0){

    cout<<endl<<"best case"<<endl; }

    else{

 

    cout <<endl<<bs<<endl;

}

 

    if(ws < 60){

    cout<<"worst case"; }

    else{

 

    cout << ws;

}

 

}

 


陣列的範圍是從0開始到陣列長度-1,所以你很多地方都超出範圍了

 
ZeroJudge Forum