508 条题解
-
0雪虎 LV 7 @ 2018-11-25 17:26:07
c++代码
#include<bits/stdc++.h>
using namespace std;
int n,sum,ans=1;
struct Int{
char mz[20],gb,xb;
int qm,py,lv,tsum;
void input(){
cin>>mz;
cin>>qm;
cin>>py;
cin>>gb;
cin>>xb;
cin>>lv;
}
void output(){
printf("%s\n",mz);
printf("%d\n",tsum);
}
void ys(){
if(qm>80 && lv>=1){
sum+=8000;
tsum+=8000;
}
}
void ws(){
if(qm>85 && py>80){
sum+=4000;
tsum+=4000;
}
}
void cj(){
if(qm>90){
sum+=2000;
tsum+=2000;
}
}
void xbj(){
if(qm>85 && xb=='Y'){
sum+=1000;
tsum+=1000;
}
}
void bj(){
if(py>80 && gb=='Y'){
sum+=850;
tsum+=850;
}
}
}a[101];
int main(){
scanf("%d",&n);
for(int i=1;i<=n;i++){
a[i].input();
a[i].ys();
a[i].ws();
a[i].cj();
a[i].xbj();
a[i].bj();
}
for(int i=2;i<=n;i++)
if(a[ans].tsum<a[i].tsum) ans=i;
a[ans].output();
printf("%d",sum);
return 0;
} -
02018-11-07 14:42:46@
#include <iostream>
#include <string>
using namespace std;
int main()
{
string name[101]; //学生名字
int qimo[101],banji[101]; //期末成绩,班级成绩
char xuesheng[101],xibu[101];//学生干部,西部地区
int lunwen[101]; //论文数量
int n,ans=0; //n个学生,总的奖学金
int money; //这就是神奇之处,不需要存储每个学生的奖学金
int max1=-1; //记录最多奖学金
string maxstudent; //记录最多奖学金获得者cin>>n;
for(int i=1;i<=n;i++) //开始循环啦
{
money=0; //刚开始每个人都没有钱cin>>name[i]>>qimo[i]>>banji[i]>>xuesheng[i]>>xibu[i]>>lunwen[i]; //输入一遍
if(qimo[i]>80 && lunwen[i]>=1) money+=8000;
if(qimo[i]>85 && banji[i]>80) money+=4000;
if(qimo[i]>90) money+=2000;
if(qimo[i]>85 && xibu[i]=='Y') money+=1000;
if(banji[i]>80 && xuesheng[i]=='Y') money+=850;ans+=money; //总的奖学金要加上去
if(money>max1) //计算最多奖学金,因为要输出最先出现的学生,所以等于就不用了
{
max1=money;
maxstudent=name[i];//记录奖学金最多者的姓名
}}
cout<<maxstudent<<endl<<max1<<endl<<ans;//输出,结束
return 0; //没有renturn 0也能AC,不过最好加上
} -
02018-11-05 13:48:26@
简单题,结构体+排序一边走起
#include<bits/stdc++.h> using namespace std; struct student{ string name; int cj1,cj2; char gb,xb; int lw; int num,ans=0; }d[100000]; int n,total=0; bool cmp(student a,student b) { if(a.ans==b.ans) return a.num<b.num; else return a.ans>b.ans; } int main() { cin>>n; for(int i=1; i<=n; i++) { cin>>d[i].name>>d[i].cj1>>d[i].cj2>>d[i].gb>>d[i].xb>>d[i].lw; d[i].num=i; if(d[i].cj1>80 && d[i].lw>=1) d[i].ans+=8000; if(d[i].cj1>85 && d[i].cj2>80) d[i].ans+=4000; if(d[i].cj1>90) d[i].ans+=2000; if(d[i].xb=='Y' && d[i].cj1>85) d[i].ans+=1000; if(d[i].gb=='Y' && d[i].cj2>80) d[i].ans+=850; total+=d[i].ans; } sort(d+1,d+n+1,cmp); cout<<d[1].name<<endl<<d[1].ans<<endl<<total<<endl; return 0; }
-
02018-10-10 16:07:48@
#include "stdafx.h"
#include <iostream>
#include <string>using namespace std;
struct stu {
string name;
int qm, bj, lw;
char gb, xb;
int jx=0;};
int main()
{
using namespace std;int rs;
cin >> rs;stu* xs = new stu[rs];
for (int i = 0; i < rs; i++) {
cin >> xs[i].name >> xs[i].qm >> xs[i].bj >> xs[i].gb >> xs[i].xb >> xs[i].lw;
}for (int i = 0; i < rs; i++) {
if (xs[i].qm>80 && xs[i].lw >= 1) xs[i].jx += 8000;
if (xs[i].qm>85 && xs[i].bj>80) xs[i].jx += 4000;
if (xs[i].qm>90) xs[i].jx += 2000;
if (xs[i].qm>85 && xs[i].xb == 'Y') xs[i].jx += 1000;
if (xs[i].bj>80) xs[i].jx += 850;
}int max = 0;
int a = 0;
for (int i = 0; i<rs; i++) {
a += xs[i].jx;
if (xs[i].jx>xs[max].jx) {
max = i;
}
}
cout << xs[max].name << endl;
cout << xs[max].jx << endl;
cout << a << endl;}
-
02018-10-09 10:43:55@
#include<iostream> #include<cstdio> #include<algorithm> using namespace std; struct student{ string name; int qimo; int banping; char monitor; char west; int lun; int money=0; int num; }; bool cmp(student x,student y){ if(x.money !=y.money ) return x.money >y.money ; return x.num <y.num ; } int main(){ int n; scanf("%d",&n); student ss[n]; long long sum=0; for(int i=0;i<n;i++){ ss[i].num =i; cin>>ss[i].name >>ss[i].qimo >>ss[i].banping >>ss[i].monitor >>ss[i].west >>ss[i].lun ; if(ss[i].qimo >80&&ss[i].lun >=1) ss[i].money +=8000; if(ss[i].qimo >85&&ss[i].banping >80) ss[i].money +=4000; if(ss[i].qimo >90) ss[i].money +=2000; if(ss[i].qimo >85&&ss[i].west=='Y') ss[i].money +=1000; if(ss[i].banping >80&&ss[i].monitor =='Y') ss[i].money +=850; sum+=ss[i].money ; } sort(ss,ss+n,cmp); cout<<ss[0].name <<endl<<ss[0].money <<endl<<sum<<endl; return 0; }
-
02018-09-27 21:07:34@
WA大家能帮我看看怎么错了吗。
```cpp
#include<iostream>
#include<string>
using namespace std;
class stu
{
public:
stu()
{
name ="kk" ;
qm = 0;
py = 0;
gb = 'l';
xb = 'l';
lw = 0;
}stu (string n,int q,int p,char g,char x,int l)
{
name =n ;
qm = q;
py = p;
gb = g;
xb = x;
lw = l;
}
void xg(string n,int q,int p,char g,char x,int l)
{name =n ;
qm = q;
py = p;
gb = g;
xb = x;
lw = l;
}void shuchu()
{
cout<<name<<endl;
}
int jxj()
{ int s=0;
if(qm>80&&lw>0) s+=8000;
if(qm>85&&py>80) s+=4000;
if(qm>90) s+=2000;
if(qm>85&&xb=='Y') s+=1000;
if(py>80&&gb=='Y') s+=850;
return s;
}private:
string name;
int qm;
int py;
char gb;
char xb;
int lw;
};
int main()
{ stu s[101];
int N;
cin>>N;
int q,p,l,nam=0;
string n;
char g,x;
for(int i = 0;i<N;i++)
{
cin>>n>>q>>p>>g>>x>>l;
s[i].xg(n,q,p,g,x,l);
}
for(int m = 0;m<N;m++)
{
nam+=s[m].jxj();
if(s[m].jxj()>s[100].jxj())
s[100]=s[m];}
s[100].shuchu();
cout<<s[99].jxj()<<endl<<nam;
return 0;
} -
02018-09-12 22:03:06@
#[derive(Debug)] struct Student { name: String, ave_score: i32, appraisal_score: i32, is_cadre: bool, is_west: bool, paper_count: i32, } impl Student { fn get_award(&self) -> usize { let mut award: usize = 0; if self.ave_score > 80 && self.paper_count >= 1 { award += 8000; }; if self.ave_score > 85 && self.appraisal_score > 80 { award += 4000; }; if self.ave_score > 90 { award += 2000; }; if self.ave_score > 85 && self.is_west { award += 1000; }; if self.appraisal_score > 80 && self.is_cadre { award += 850; }; award } } use std::vec::Vec; fn main() { let mut buf = String::new(); std::io::stdin().read_line(&mut buf).unwrap(); let student_count: usize = buf.trim().parse().unwrap(); let mut students: Vec<Student> = Vec::with_capacity(student_count); for _ in 0..student_count { buf.clear(); std::io::stdin().read_line(&mut buf).unwrap(); let res: Vec<&str> = buf.trim().split(" ").collect(); let name = res.get(0).unwrap(); let ave_score: i32 = res.get(1).unwrap().parse().unwrap(); let appraisal_score: i32 = res.get(2).unwrap().parse().unwrap(); let is_cadre = match res.get(3).unwrap() { &"Y" => true, &"N" => false, _ => false, }; let is_west = match res.get(4).unwrap() { &"Y" => true, &"N" => false, _ => false, }; let paper_count: i32 = res.get(5).unwrap().parse().unwrap(); students.push(Student { name: String::from(*name), ave_score:ave_score, appraisal_score:appraisal_score, is_cadre:is_cadre, is_west:is_west, paper_count:paper_count, }) } let max_award_student = students.iter().max_by_key(|s| s.get_award()).unwrap(); println!("{}", max_award_student.name); println!("{}", max_award_student.get_award()); println!("{}", students.iter().fold(0, |acc,s| acc+s.get_award())); }
-
02018-09-07 20:43:32@
#include<iostream>
using namespace std;
struct tstudent{
string name,m,n;
int f,c,num;
};
int N,sum,n1=0,n2=0,sum1;
tstudent a[601];
int jiang(int x){
sum=0;
if(a[x].f>80&&a[x].num>=1) sum+=8000;
if(a[x].f>85&&a[x].c>80) sum+=4000;
if(a[x].f>90) sum+=2000;
if(a[x].f>85&&a[x].n=="Y") sum+=1000;
if(a[x].c>80&&a[x].m=="Y") sum+=850;
return sum;
}
int main(){
cin>>N;
for(int i=0;i<N;i++){
cin>>a[i].name>>a[i].f>>a[i].c>>a[i].m>>a[i].n>>a[i].num;
}
for(int j=0;j<N;j++){
if(jiang(j)>n2){
n2=jiang(j);
n1=j;
}
sum1+=jiang(j);
}
cout<<a[n1].name<<endl<<jiang(n1)<<endl<<sum1;
return 0;}
-
02018-09-07 20:39:37@
#include <iostream>
#include <cstring>
using namespace std;
struct student
{
string name;
int terminal; // 期末平均成绩
int evaluation; // 班级评议成绩
char cadres; // 是否学生干部
char west; // 是否西部省份
int papers; // 论文数
int money=0; // 获取的奖学金
} stu[100];
int main()
{
int N, i, index, totalMoney;
cin >> N;
for (i=0; i<N; i++){
cin >> stu[i].name >> stu[i].terminal >> stu[i].evaluation >> stu[i].cadres >> stu[i].west >> stu[i].papers;
if (stu[i].terminal>80 && stu[i].papers>0) stu[i].money += 8000; // 院士奖学金
if (stu[i].terminal>85 && stu[i].evaluation>80) stu[i].money += 4000; // 五四奖学金
if (stu[i].terminal>90) stu[i].money += 2000; // 成绩优秀奖
if (stu[i].terminal>85 && stu[i].west=='Y') stu[i].money += 1000; // 西部奖学金
if (stu[i].evaluation>80 && stu[i].cadres=='Y') stu[i].money += 850; // 班级贡献奖}
index = 0;
totalMoney = stu[0].money;
for (i=1; i<N; i++){
if (stu[i].money > stu[index].money)
index = i;
totalMoney += stu[i].money;
}
cout << stu[index].name << endl;
cout << stu[index].money << endl;
cout << totalMoney << endl;
return 0;
} -
02018-08-31 19:48:01@
不喜勿喷,谢谢。
以下题解
若有同雷者,纯属巧合#include <iostream> #include <string> using namespace std; struct Student { char name[20]; //姓名 int score1; //期末成绩 int score2; //班级成绩 char leader; //是否是班干部 char weststudent; //是否是西部学生 int article; //论文数 int money; //个人总奖金 }; Student a[100]; int main() { int max=0; //学生编号 int sum=0; //总奖金 int n; //学生总数 cin>>n; //输入学生总数 for(int i=0; i<n; i++) { cin>>a[i].name; cin>>a[i].score1; cin>>a[i].score2; cin>>a[i].leader; cin>>a[i].weststudent; cin>>a[i].article; } for(int j=0; j<n; j++) { a[j].money=0; if(a[j].score1>80&&a[j].article>=1) a[j].money+=8000; if(a[j].score1>85&&a[j].score2>80) a[j].money+=4000; if(a[j].score1>90) a[j].money+=2000; if(a[j].score1>85&&a[j].weststudent=='Y') a[j].money+=1000; if(a[j].score2>80&&a[j].leader=='Y') a[j].money+=850; sum+=a[j].money; } for(int k=0; k<n; k++) { if(a[k].money>a[max].money) max=k; } cout<<a[max].name<<endl; cout<<a[max].money<<endl; cout<<sum; return 0; }
-
02018-08-07 11:56:40@
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
struct node{
string name;
int qimo;
int banji;
char bangan;
char xibu;
int len;
}a[101];
int b[101]={0};
int main(){
int n;
cin>>n;
for(int i=0;i<n;i++){
cin>>a[i].name>>a[i].qimo>>a[i].banji>>a[i].bangan>>a[i].xibu>>a[i].len;
}
for(int i=0;i<n;i++){
if(a[i].qimo>80&&a[i].len>=1)
{
b[i]+=8000;
}
if(a[i].qimo>85&&a[i].banji>80)
{
b[i]+=4000;
}
if(a[i].qimo>90)
{
b[i]+=2000;
}
if(a[i].qimo>85&&a[i].xibu=='Y')
{
b[i]+=1000;
}
if(a[i].banji>80&&a[i].bangan=='Y')
{
b[i]+=850;
}
}
int max=b[0],maxi,sum=0;
for(int i=1;i<n;i++)
{
if(max<b[i])
{
max=b[i];
maxi=i;
}
}
cout<<a[maxi].name<<endl<<b[maxi]<<endl;
for(int i=0;i<n;i++)
{
sum+=b[i];
}
cout<<sum;
return 0;
} -
02018-07-20 23:22:50@
#include <stdio.h>
struct stu
{
char a[20],d,e;
int b,c,f,g;
};
int main()
{
int n,i=0,p=0,g=0;
scanf ("%d",&n);
struct stu s[n];
for (;i<n;i++)
{
scanf("%s %d %d %c %c %d",&s[i].a,&s[i].b,&s[i].c,&s[i].d,&s[i].e,&s[i].f);
s[i].g=0;
if(s[i].b>80&&s[i].f)s[i].g+=8000;
if(s[i].b>85&&s[i].c>80)s[i].g+=4000;
if(s[i].b>90)s[i].g+=2000;
if(s[i].b>85&&s[i].e=='Y')s[i].g+=1000;
if(s[i].c>80&&s[i].d=='Y')s[i].g+=850;
if(s[i].g>s[p].g)p=i;
g+=s[i].g;
}
printf("%s\n%d\n%d",s[p].a,s[p].g,g);
return 0;
} -
02018-07-12 17:32:26@
#include <stdio.h> typedef struct { char name[20]; //姓名 int final; //期末成绩 int asse; //评定成绩 char leader; char western; //是否西部 int paper; //发表论文 int salary; //奖金 }student; int salary(student p){ //计算奖金 int average = p.final; int money = 0; if(average > 80 && p.paper >= 1) money = money + 8000; if(average > 85 && p.asse >80) money = money + 4000; if(average > 90) money = money + 2000; if(average > 85 && p.western =='Y') money = money + 1000; if(p.asse > 80 && p.leader == 'Y') money = money + 850; return money; } int main(int argc, char const *argv[]) { //录入学生信息 int N; //学生总数 scanf("%d",&N); student temp; student a[N]; for (int i = 0; i < N; i++) //输入信息 { scanf("%s %d %d %c %c %d ",&a[i].name,&a[i].final,&a[i].asse,&a[i].leader,&a[i].western,&a[i].paper); a[i].salary = salary(a[i]); } //求最多奖学金的学生 for(int i = 1;i < N;i++){ if(a[i].salary > a[0].salary){ temp = a[i]; a[i] = a[0]; a[0] = temp; } } printf("%s\n%d\n",a[0].name,a[0].salary); //输出总奖学金 int all = 0; for (int i = 0; i < N; i++) { all = all + a[i].salary; } printf("%d\n",all ); return 0; }
-
02018-07-12 15:13:33@
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
char s[100][20],c1,c2;
int n,sum=0,max=0,score1,score2,num,a,b,k;
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
scanf("%s %d %d %c %c %d",&s[i],&score1,&score2,&c1,&c2,&num);
a=c1=='Y'?1:0;
b=c2=='Y'?1:0;
int tmp=0;
if((score1>80)&&(num>0))tmp+=8000;
if((score1>85)&&(score2>80))tmp+=4000;
if(score1>90)tmp+=2000;
if(b&&(score1>85))tmp+=1000;
if(a&&(score2>80))tmp+=850;
sum+=tmp;
if(tmp>max){max=tmp;k=i;}
}
printf("%s\n%d\n%d\n",s[k],max,sum);
return 0;
} -
02018-06-30 21:07:19@
刚从一个pas党转为c++党,第一次写的代码。。
```cpp
#include<iostream>
#include<cstdio>
#include<string.h>
#include<ctype.h>
using namespace std;
int main()
{
int n,qm,by,lw,len,i,zh,num,max,j,len1;
char k,xb,xg,name[100],zd[100];scanf("%d\n",&n);
k=' ';
for (i=0; i<=90; i++)
{
name[i]=k;
zd[i]=k;
}
max=0; zh=0; len=0; len1=0;
for (i=1; i<=n; i++)
{
len=0;
if (i<n)
scanf("%s %d %d %c %c %d\n",&name,&qm,&by,&xg,&xb,&lw);
else
scanf("%s %d %d %c %c %d",&name,&qm,&by,&xg,&xb,&lw);
for (j=0; j<=50; j++)
if (isalpha(name[j])!=0)
len++;
else
break;
num=0;
if (qm>80 && lw>0)
num=num+8000;
if (qm>85 && by>80)
num=num+4000;
if (qm>90)
num=num+2000;
if (qm>85 && xb=='Y')
num=num+1000;
if (by>80 && xg=='Y')
num=num+850;
if (num>max)
{
max=num;
for (j=0; j<len; j++)
zd[j]=name[j];
len1=len;
}
zh=zh+num;
}
for (i=0; i<len1; i++)
printf("%c",zd[i]);
printf("\n");
printf("%d\n",max);
printf("%d\n",zh);
return 0;
}
``` -
02018-06-01 18:09:01@
此题考查的是基础知识,NOIP的标准题解,OJ评测状态。
这道题需要提醒的是:
1)此题不能用sort()排序,sort是一个不稳定的排序算法,否则会有一个测试点不能AC(#9textdata)。改正方法很简单:
if (max<a[i].sum)//判断最大值-奖学金最多
{
max=a[i].sum;//找到并赋值
big=i;//将它的id标注,以备输出好用
}
2)结构体定义:
struct 结构体名{
成员
}结构体数组;标程如下:
#include <iostream>
#include <string>
using namespace std;
struct student{
string name;//姓名
int s1;//期末平均得分
int s2;//评议成绩
char x;//是否是班干部
char y;//是否是西部学生
int t;//发表的议论次数
int sum;//总奖学金
}a[101];//定义结构体数组
int main()
{
int n,total=0,max=-1,big;//total_n名同学奖学金总和 max_n名同学中的奖学金的那名同学 big_那名同学的编号
cin>>n;
for (int i=1;i<=n;i++)
{
cin>>a[i].name>>a[i].s1>>a[i].s2>>a[i].x>>a[i].y>>a[i].t; //输入
if (a[i].s1>80 && a[i].t>=1) a[i].sum+=8000; //1
if (a[i].s1>85 && a[i].s2>80) a[i].sum+=4000; //2
if (a[i].s1>90) a[i].sum+=2000; //3
if (a[i].s1>85 && a[i].y=='Y') a[i].sum+=1000; //4
if (a[i].s2>80 && a[i].x=='Y') a[i].sum+=850; //5
total+=a[i].sum;//求和
if (max<a[i].sum)//判断最大值
{
max=a[i].sum;
big=i;
}
}
cout<<a[big].name<<endl<<a[big].sum<<endl<<total<<endl; //输出
return 0;
} -
02018-06-01 16:39:40@
GoLang
```go
package mainimport (
"fmt"
)func main() {
var n int
fmt.Scanf("%d\n", &n)StudArr := [200]student{}
for i := 0; i < n; i++ {
var name string
var qm, bj, paper int
var IsGB, IsWest stringfmt.Scanf("%s %d %d %s %s %d\n", &name, &qm, &bj, &IsGB, &IsWest, &paper)
//fmt.Println(name, qm, IsGB, IsWest, paper)stud := student{name, qm, bj, paper, IsGB, IsWest, 0}
stud.CalcMoney()StudArr[i] = stud
}MaxMoney := 0
winner := ""
sum := 0for i := 0; i < n; i++ {
thisMoney := StudArr[i].money
sum += thisMoneyif i == 0 || thisMoney > MaxMoney {
MaxMoney = thisMoney
winner = StudArr[i].name
}
}fmt.Printf("%s\n", winner)
fmt.Printf("%d\n", MaxMoney)
fmt.Printf("%d", sum)}
type student struct {
name string
qm, bj, paper int
IsGB, IsWest string
money int
}func (p *student) CalcMoney() {
sum := 0
if p.qm > 80 && p.paper >= 1 {
sum += 8000
}if p.qm > 85 && p.bj > 80 {
sum += 4000
}if p.qm > 90 {
sum += 2000
}if p.qm > 85 && p.IsWest == "Y" {
sum += 1000
}if p.bj > 80 && p.IsGB == "Y" {
sum += 850
}p.money = sum
} -
02018-05-29 10:56:52@
Java满分题解
import java.io.BufferedInputStream;
import java.util.Scanner;public class Main {
public static void main(String[] args) {
Scanner s = new Scanner(new BufferedInputStream(System.in));
int n = s.nextInt();
String string = s.nextLine();
String ss[][] = new String[n][7];
int sum[] = new int[n];
int max = 0;
int max_index = 0;
int sum_all = 0;for (int i = 0; i < n; i++) {
string = s.nextLine();
ss[i] = string.split(" ");
if (!ss[i][5].equals("0") && Integer.parseInt(ss[i][1]) > 80)
sum[i] += 8000;
if (Integer.parseInt(ss[i][2]) > 80 && Integer.parseInt(ss[i][1]) > 85)
sum[i] += 4000;
if (Integer.parseInt(ss[i][1]) > 90)
sum[i] += 2000;
if (Integer.parseInt(ss[i][1]) > 85 && ss[i][4].equals("Y"))
sum[i] += 1000;
if (Integer.parseInt(ss[i][2]) > 80 && ss[i][3].equals("Y"))
sum[i] += 850;
if (max < sum[i]){
max = sum[i];
max_index = i;
}
sum_all+=sum[i];
}
System.out.println(ss[max_index][0]);
System.out.println(max);
System.out.println(sum_all);
}
} -
02018-04-23 16:24:03@
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
//#define maxn 20000
//int key[maxn];
int main(int argc, char** argv)
{
//freopen("2005t1.in","r",stdin);
//freopen("2005t1.out","w",stdout);
long n,c1,c2,lw,k1,k2=0,max=0;
char bj,xb,kg,str[30],str1[30];//kg为空格占位
scanf("%ld",&n);
for(int i=0;i<n;i++)
{
k1=0;
scanf("%s%ld%ld%c%c%c%c%c%ld",str1,&c1,&c2,&kg,&bj,&kg,&xb,&kg,&lw);//c单个s多个if(c1>80&&lw>0)
k1=k1+8000;
if(c1>85&&c2>80)
k1=k1+4000;
if(c1>90)
k1=k1+2000;
if(c1>85&&xb=='Y')
k1+=1000;
if(c2>80&&bj=='Y')//等号后单引号引起字符
k1+=850;
k2=k2+k1;if(k1>max)
{
max=k1; //外部变量进行累加
strcpy(str,str1);//输出人名
}}
// printf("%ld\n",n); 题目不要求输出
printf("%s\n",str);
printf("%ld\n",max);
printf("%ld",k2);
return 0;
}/* long int a[101],b[101],c[101];
long int k[101],max=0,q=0,z;
char ren[101],xue[101],xi[101];
scanf("%ld",&z);
for(int i=0;i<z;i++)
{
scanf("%s ",ren[i]);
scanf("%ld ",a[i]);
scanf("%ld ",b[i]);
scanf("%s ",xue[i]);
scanf("%s ",c[i]);
k[i]=0;
if(a[i]>80&&c[i>=1])
{
k[i]=k[i]+8000;
}
if(a[i]>85&&b[i]>80)
{
k[i]=k[i]+4000;
}
if(a[i]>90)
{
k[i]=k[i]+2000;
}
if(a[i]>85&&xi[i]=='Y')
{
k[i]=k[i]+1000;
}
if(a[i]>80&&xue[i]=='Y')
{
k[i]=k[i]+850;
}
}for(int i=0;i<100;i++)
{
if(k[i]<k[i+1])
{
max=k[i+1];
}
q=q+k[i];
}
printf("%ld",q);
return 0;
}*/ -
02018-04-06 12:42:47@
using System; using System.Collections.Generic; namespace ConsoleApp16 { class Program { static void Main(string[] args) { int a = Convert.ToInt32(Console.ReadLine()); List<Student> b = new List<Student>(); for(int i=0;i<a;i++) { string[] l = Console.ReadLine().Split(' '); b.Add(new Student { name = l[0], a = Convert.ToInt32(l[1]), b = Convert.ToInt32(l[2]), c = (l[3] == "Y" ? true : false), d = (l[4] == "Y" ? true : false), e = Convert.ToInt32(l[5]) }); } b.Sort(); Console.WriteLine(b[0]); Console.WriteLine(b[0].Money); int c = 0; foreach(Student d in b) { c += d.Money; } Console.WriteLine(c); } } public class Student:IComparable { public int a; public int b; public bool c; public bool d; public int e; public string name; public int Money => (M1() ? 8000 : 0) + (M2() ? 4000 : 0) + (M3() ? 2000 : 0) + (M4() ? 1000 : 0) + (M5() ? 850 : 0); public bool M1() { if(a>80&&e>=1) { return true; } else { return false; } } public bool M2() { if(a>85&&b>80) { return true; } else { return false; } } public bool M3() { if(a>90) { return true; } else { return false; } } public bool M4() { if(a>85&&d) { return true; } else { return false; } } public bool M5() { if(b>80&&c) { return true; } else { return false; } } public static bool operator >(Student a, Student b) => (a.Money > b.Money ? true : false); public static bool operator <(Student a, Student b) => (a.Money < b.Money ? true : false); public override string ToString() { return name; } public int CompareTo(object obj) { if(obj is Student) { Student a = obj as Student; return a.Money - Money; } else { return 0; } } } }