--- 題型 ---
放剩下 相關的題目 ψ(._. )>
/*
* zerojudge
* b428. 凱薩加密
* C++
* AC (15ms, 328KB)
*/
#include<bits/stdc++.h>
using namespace std;
int main(){
bool isP1 = true;
string s;
char p1,p2;
while(cin >> s){
if(isP1){
p1 = s[0];
}else{
p2 = s[0];
int password = p2-p1;
if(password<0){
password+=26;
}
cout << password << endl;
}
isP1 = !isP1;
}
return 0;
}
/*
* zerojudge
* b964. 1. 成績指標
* C++
* AC (2ms, 332KB)
*/
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >> n;
int min=-111;
int max=999;
int x[n];
//
for(int i=0;i<n;i++){
int a;
cin >> a;
x[i]=a;
if(a<60 && min<a){
min=a;
}
if(a>=60 && a<max){
max=a;
}
}
////
sort(x,x+n);
for(int i=0;i<n;i++){
cout << x[i] << " ";
}
cout << endl;
//
if(min==-111){
cout << "best case" << endl;
}else{
cout << min << endl;
}
//
if(max==999){
cout << "worst case" << endl;
}else{
cout << max << endl;
}
//
return 0;
}
/*
* zerojudge
* k605. 班級成績單
* C++
* AC (3ms, 324KB)
*/
#include <bits/stdc++.h>
using namespace std;
struct define_test{
int num;
string name;
int s[5];
int score;
int rank;
};
bool cmp(define_test t1,define_test t2){
return t1.score>t2.score || (t1.score==t2.score && t1.num<t2.num);
}
int main(){
int N;
cin >> N;
define_test test[N];
for(int i=0;i<N;i++){
cin >> test[i].num >> test[i].name;
int a,b,c,d,e;
cin >> a >> b >> c >> d >> e;
test[i].s[0] = a;
test[i].s[1] = b;
test[i].s[2] = c;
test[i].s[3] = d;
test[i].s[4] = e;
test[i].score = a+b+c+d+e;
}
//
sort(test,test+N,cmp);
//
int rank = 1;
int x=0;
test[0].rank = rank;
for(int i=0;i<N;i++){
if(i!=0 && test[i].score != test[i-1].score){
rank=test[i-1].rank+x;
x=0;
}
x++;
test[i].rank = rank;
}
//
for(int i=0;i<N;i++){
cout << test[i].num << " " << test[i].name << " ";
cout << test[i].s[0] << " ";
cout << test[i].s[1] << " ";
cout << test[i].s[2] << " ";
cout << test[i].s[3] << " ";
cout << test[i].s[4] << " ";
cout << test[i].score << " ";
cout << test[i].rank << "\n";
}
return 0;
}
Last updated
Was this helpful?