510 条题解
-
0
芙兰朵露•斯卡雷特 LV 8 @ 2016-02-22 14:27:50
#**面向对象的写法**
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) { Scanner sc=new Scanner(new BufferedReader(new InputStreamReader(System.in))); student[] students=new student[sc.nextInt()]; for (int i = 0; i < students.length; i++) students[i]=new student(sc.next(),sc.nextInt(),sc.nextInt(),sc.next().equals("Y")?true:false,sc.next().equals("Y")?true:false,sc.nextInt()); Arrays.sort(students, new comparator()); int total = 0; for (student student : students) total+=student.getMoney(); System.out.println(students[students.length-1].getName()+"\n"+students[students.length-1].getMoney()+"\n"+total); } } //奖学金比较器 class comparator implements Comparator<student>{ public int compare(student o1, student o2) { if(o1.getMoney()!=o2.getMoney()) return o1.getMoney()>o2.getMoney()?1:-1; else return 0; } } class student{ private String name; private int averageScore; private int classScore; private boolean isCadres; private boolean isEast; private int num; private int money=0; public student(String name,int averageScore,int classScore,boolean isCadres,boolean isEast,int num) { this.name=name; this.averageScore=averageScore; this.classScore=classScore; this.isCadres=isCadres; this.isEast=isEast; this.num=num; this.money+=(averageScore>80&&num>=1)?8000:0; this.money+=(averageScore>85&&classScore>80)?4000:0; this.money+=averageScore>90?2000:0; this.money+=(averageScore>85&&isEast)?1000:0; this.money+=(classScore>80&&isCadres)?850:0; } //getter和setter public String getName() { return name; } public void setName(String name) { this.name = name; } public int getAverageScore() { return averageScore; } public void setAverageScore(int averageScore) { this.averageScore = averageScore; } public int getClassScore() { return classScore; } public void setClassScore(int classScore) { this.classScore = classScore; } public boolean isCadres() { return isCadres; } public void setCadres(boolean isCadres) { this.isCadres = isCadres; } public boolean isEast() { return isEast; } public void setEast(boolean isEast) { this.isEast = isEast; } public int getNum() { return num; } public void setNum(int num) { this.num = num; } public int getMoney() { return money; } public void setMoney(int money) { this.money = money; } }
-
02016-02-18 11:01:31@
/* *********************************************** Author :guanjun Created Time :2016/2/18 9:23:52 File Name :vijos1001.cpp ************************************************ */ #include <iostream> #include <cstring> #include <cstdlib> #include <stdio.h> #include <algorithm> #include <vector> #include <queue> #include <set> #include <map> #include <string> #include <math.h> #include <stdlib.h> #include <iomanip> #include <list> #include <deque> #include <stack> #define ull unsigned long long #define ll long long #define mod 90001 #define INF 0x3f3f3f3f #define maxn 10000+10 #define cle(a) memset(a,0,sizeof(a)) const ull inf = 1LL << 61; const double eps=1e-5; using namespace std; struct node{ string name; int avg; int bs; int ganbu; int xibu; int lunwen,money; node(){ ganbu=0; xibu=0; lunwen=0; money=0; } }nod[110]; int main() { #ifndef ONLINE_JUDGE //freopen("in.txt","r",stdin); #endif //freopen("out.txt","w",stdout); int n; char a,b; while(cin>>n){ for(int i=1;i<=n;i++){ cin>>nod[i].name>>nod[i].avg>>nod[i].bs>>a>>b>>nod[i].lunwen; if(a=='Y')nod[i].ganbu=1; if(b=='Y')nod[i].xibu=1; } int sum=0,mid; string mm; int Max=-INF; for(int i=1;i<=n;i++){ if(nod[i].avg>80&&nod[i].lunwen>=1){ nod[i].money+=8000; } if(nod[i].avg>85&&nod[i].bs>80){ nod[i].money+=4000; } if(nod[i].avg>90)nod[i].money+=2000; if(nod[i].avg>85&&nod[i].xibu)nod[i].money+=1000; if(nod[i].bs>80&&nod[i].ganbu)nod[i].money+=850; sum+=nod[i].money; if(nod[i].money>Max)Max=nod[i].money,mid=i; //cout<<nod[i].money<<endl; } cout<<nod[mid].name<<endl; cout<<nod[mid].money<<endl; cout<<sum<<endl; } return 0; }
-
02016-01-08 19:36:36@
#include <iostream>
#include <cstring>
using namespace std;struct student
{
string name;
int qmcj;
int pycj;
char gb;
char west;
int lw;
int sum=0;
};student a[101];
int i, n;
long long sum = 0;
int maxpos, maxl=0;int main()
{
cin >> n;
for (i = 1; i <= n; i++)
{
cin>>a[i].name>>a[i].qmcj>>a[i].pycj>>a[i].gb>>a[i].west>>a[i].lw;
if (a[i].qmcj > 80 && a[i].lw >= 1)
a[i].sum += 8000;
if (a[i].qmcj > 85 && a[i].pycj > 80)
a[i].sum += 4000;
if (a[i].qmcj > 90)
a[i].sum += 2000;
if (a[i].qmcj > 85 && a[i].west == 'Y')
a[i].sum += 1000;
if (a[i].pycj > 80 && a[i].gb == 'Y')
a[i].sum += 850;
sum += a[i].sum;
if (a[i].sum > maxl)
{
maxpos = i;
maxl=a[i].sum;
}
cin.clear();
}
cout << a[maxpos].name << endl;;
cout << a[maxpos].sum << endl;
cout << sum;
return 0;
} -
02015-12-29 18:35:26@
各位大神求找错
第二个测试点没过
O(∩_∩)O谢谢
type rqq=record
name:string[20];
qm:0..100;
bj:0..100;
gb:char;
xb:char;
lw:0..10;
money:0..15850;
end;
var n,i,b,c:integer;
s:longint;
a:char;
k:array[1..105] of rqq;
begin
readln(n);
for i:=1 to n do
begin
read(a);
while a<>' ' do
begin k[i].name:=k[i].name+a; read(a); end;
read(k[i].qm,k[i].bj);
read(a);
read(k[i].gb);
read(a);
read(k[i].xb,k[i].lw);
end;
for i:=1 to n do
begin
if (k[i].qm>80)and(k[i].lw>0) then k[i].money:=k[i].money+8000;
if (k[i].qm>85)and(k[i].bj>80) then k[i].money:=k[i].money+4000;
if k[i].qm>90 then k[i].money:=k[i].money+2000;
if (k[i].qm>85)and(k[i].xb='Y') then k[i].money:=k[i].money+1000;
if (k[i].bj>80)and(k[i].gb='Y') then k[i].money:=k[i].money+850;
s:=s+k[i].money;
end;
b:=-1;
for i:=1 to n do
if k[i].money>b then
begin b:=k[i].money; c:=i; end;
writeln(k[c].name);
writeln(b);
writeln(s);
end. -
02015-12-20 21:08:46@
一开始以为要开数组,做完了才发现多此一举了……
可以声明一个记录集类型来存所有数据,每行读入每行计算。
要注意读入名字、是否为班干部、是否为西部学生时的数据采集(烦请大神指教)
后附本蒟蒻题解……
###Pascal Code
program p1001;
type
student=record
na:string;
qm,bj,artical,sum:longint;
gb,west:boolean;
end;
var
s:array[1..100] of student;
n,i,j,sum,max,t:longint;
c:char;
begin
for i:=1 to 100 do
begin
s[i].na:='';
s[i].gb:=False;
s[i].west:=False;
s[i].sum:=0;
end;
max:=0; sum:=0;
readln(n);for i:=1 to n do //read
begin
read(c);
while not (c=' ') do
begin
s[i].na:=s[i].na+c;
read(c);
end;
read(s[i].qm,s[i].bj);
for j:=1 to 4 do
begin
read(c);
if c=' 'then continue;
if (j=2) and (c='Y') then s[i].gb:=True;
if (j=4) and (c='Y') then s[i].west:=True;
end;
readln(s[i].artical); //End read
//Main
t:=0;
if (s[i].qm>80) and (s[i].artical>=1) then inc(t,8000);
if (s[i].qm>85) and (s[i].bj>80) then inc(t,4000);
if s[i].qm>90 then inc(t,2000);
if (s[i].qm>85) and (s[i].west=True) then inc(t,1000);
if (s[i].bj>80) and (s[i].gb=True) then inc(t,850);
if t>s[max].sum then max:=i;
s[i].sum:=t;
sum:=sum+t;
end;
//End Main
writeln(s[max].na); //Write
writeln(s[max].sum);
writeln(sum); //End Write
{for i:=1 to n do //Test
writeln(s[i].na,' ',s[i].qm,' ',s[i].bj,' ',s[i].gb,
' ',s[i].west,' ',s[i].artical);} //End Test
end. -
02015-12-12 12:44:07@
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
struct node
{
char map[100];
int x,y,z;
char w1,w2;
int m;
int ma;
}num[10000];
bool cmp(node a,node b)
{
if(a.m==b.m)
return a.ma<b.ma;
else
return a.m>b.m;
}
int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
int ans=0;
int i,j;
for(i=0;i<n;i++)
{
scanf("%s",num[i].map);
scanf("%d%d",&num[i].x,&num[i].y);
getchar();
scanf("%c",&num[i].w1);
getchar();
scanf("%c",&num[i].w2);
scanf("%d",&num[i].z);
num[i].ma=i;
num[i].m=0;
// printf("%s %d %d %c %c %d\n",num[i].map,num[i].x,num[i].y,num[i].w1,num[i].w2,num[i].z);
}
for(i=0;i<n;i++)
{
if(num[i].x>80&&num[i].z>=1)
{
num[i].m+=8000;
}
if(num[i].x>85&&num[i].y>80)
{
num[i].m+=4000;
}
if(num[i].x>90)
num[i].m+=2000;
if(num[i].x>85&&num[i].w2=='Y')
num[i].m+=1000;
if(num[i].y>80&&num[i].w1=='Y')
num[i].m+=850;
ans+=num[i].m;
}
sort(num,num+n,cmp);
printf("%s\n",num[0].map);
printf("%d",num[0].m);
printf("\n%d\n",ans);
}
return 0;
} -
02015-12-05 21:36:19@
测试数据 #0: Wrong answer, time = 150ms, mem = 1042KiB, score = 0
测试数据 #1: Wrong answer, time = 150ms, mem = 1042 KiB, score = 0
测试数据 #2: Wrong answer, time = 150 ms, mem = 1042 KiB, score = 0
测试数据 #3: Wrong answer, time = 150 ms, mem = 1042 KiB, score = 0
测试数据 #4: Wrong answer, time = 150 ms, mem = 1042 KiB, score = 0
测试数据 #5: Wrong answer, time = 150 ms, mem = 1042 KiB, score = 0
测试数据 #6: Wrong answer, time = 150 ms, mem = 1042 KiB, score = 0
测试数据 #7: Wrong answer, time = 150 ms, mem = 1042 KiB, score = 0
测试数据 #8: Wrong answer, time = 150 ms, mem = 1042 KiB, score = 0
测试数据 #9:Wrong answer, time = 150 ms, mem = 1042 KiB, score = 0
Wrong answer, time = 1500 ms, mem = 1042 KiB, score = 0
var
a,b,c:array[1..100000]of string;
n,i,j,k,p,d,e,f,f2,g:longint;
c1,c2,c3,c4:char;
z1,z2,z3,z4,z5:array[1..1000000]of longint;
bo:boolean;
begin
readln(n);
for i:=1 to n do
readln(a[i]);
p:=0;d:=0; fillchar(z1,sizeof(z1),0); e:=0;
for i:=1 to n do
begin
k:=0;
for j:=1 to length(a[i]) do
while a[i][j]<>' ' do
begin
b[i][j]:=a[i][j];
inc(k);
end;
k:=k+1;
for j:=k to length(a[i]) do
while a[i][j]<>' ' do
begin
p:=p+ord(a[i][j])-48;
inc(k);
end;
k:=k+1;
for j:=k to length(a[i]) do
while a[i][j]<>' ' do
begin
d:=d+ord(a[i][j])-48;
inc(k);
end;
k:=k+1;
for j:=k to length(a[i]) do
while a[i][j]<>' ' do
begin
c1:=a[i][j];
inc(k);
end;
k:=k+1;
for j:=k to length(a[i]) do
while a[i][j]<>' ' do
begin
c2:=a[i][j];
inc(k);
end;
k:=k+1;
for j:=k to length(a[i]) do
g:=ord(a[i][j])-48;
if (p>80) and (g>0) then z1[i]:=z1[i]+8000;
if (p>85) and (d>80) then z1[i]:=z1[i]+4000;
if (p>90) then z1[i]:=z1[i]+2000;
if (p>85) and ((c2='y') or (c2='Y')) then z1[i]:=z1[i]+1000;
if (p>80) and ((c1='y') or (c1='Y')) then z1[i]:=z1[i]+850;
end;
f2:=1;
repeat
bo:=true;
for i:=1 to n-f2 do
if z1[i]<z1[i+1] then
begin
c[i]:=b[i];
b[i]:=b[i+1];
b[i+1]:=c[i];
z2[i]:=z1[i];
z1[i]:=z1[i+1];
z1[i+1]:=z2[i];
end;
until bo;
for i:=1 to n do
e:=e+z1[i];
writeln(b[1]);
writeln(z1[1]);
writeln(e);
end.
无语了 -
02015-11-03 23:56:45@
###用面向对象的方法,主要为了练习类与对象的使用
#include <iostream>
#include <string>using namespace std;
void Proc1();
int main()
{
Proc1();
return 0;
}class Student
{
public:
Student(string&, short&, short&, char&, char&, short&);
Student();
Student(const Student&);
~Student();
void set_Name(string&);
void set_Final_Score(int&);
void set_Class_Score(int&);
void set_Chairman(char&);
void set_Westman(char&);
string getName();
short Final_Score();
short Class_Score();
char Chairman();
char Westman();
int Scholarship();
private:
string name;
short final_Score,class_Score,paper;
char chairman, westman;
int scholarship;
};Student::Student()
{
name = "";
final_Score = class_Score = 0;
chairman = westman = 'N';
paper = 0;
scholarship = 0;}
Student::Student(string&sname, short&FS, short&CS, char&isChairman, char&isWestman, short&npaper)
{
name = sname;
final_Score = FS;
class_Score = CS;
chairman = isChairman;
westman = isWestman;
paper = npaper;
int tmp = 0;
if (final_Score > 80 && paper >= 1) tmp += 8000;
if (final_Score > 85 && class_Score > 80) tmp += 4000;
if (final_Score > 90)tmp += 2000;
if (final_Score > 85 && westman == 'Y')tmp += 1000;
if (class_Score > 80 && chairman == 'Y')tmp += 850;
scholarship = tmp;
}
Student::Student(const Student&Stu)
{
name = Stu.name;
final_Score = Stu.final_Score;
class_Score = Stu.class_Score;
chairman = Stu.chairman;
westman = Stu.westman;
paper = Stu.paper;
scholarship = Stu.scholarship;
}Student::~Student()
{
}void Student::set_Name(string& sname)
{
name = sname;
}void Student::set_Final_Score(int&fs)
{
final_Score = fs;
}
void Student::set_Class_Score(int&cs)
{
class_Score = cs;
}
void Student::set_Chairman(char&isChairman)
{
chairman = isChairman;
}
void Student::set_Westman(char&isWestman)
{
westman = isWestman;
}
string Student::getName()
{
return name;
}
int Student::Scholarship()
{
return scholarship;
}void Proc1()
{
int n;
cin >> n;
string name_tmp;
short Final_Score, Class_Score,paper;
char isChairman, isWestman;
Student stumax;
int sum = 0;
for (int i = 0; i < n; i++)
{
cin >> name_tmp >> Final_Score >> Class_Score >> isChairman >> isWestman >> paper;
Student stu(name_tmp, Final_Score, Class_Score, isChairman, isWestman, paper);
if (stumax.Scholarship() < stu.Scholarship())
stumax = stu;
sum += stu.Scholarship();
}
cout << stumax.getName() << endl;
cout << stumax.Scholarship() << endl;
cout << sum << endl;}
-
02015-10-30 22:02:12@
果然是因为字符串数量弄错了。。。直接取30个解决。
测试数据 #0: Accepted, time = 2 ms, mem = 496 KiB, score = 10测试数据 #1: Accepted, time = 2 ms, mem = 492 KiB, score = 10
测试数据 #2: Accepted, time = 0 ms, mem = 492 KiB, score = 10
测试数据 #3: Accepted, time = 0 ms, mem = 496 KiB, score = 10
测试数据 #4: Accepted, time = 0 ms, mem = 492 KiB, score = 10
测试数据 #5: Accepted, time = 0 ms, mem = 496 KiB, score = 10
测试数据 #6: Accepted, time = 0 ms, mem = 492 KiB, score = 10
测试数据 #7: Accepted, time = 0 ms, mem = 492 KiB, score = 10
测试数据 #8: Accepted, time = 2 ms, mem = 496 KiB, score = 10
测试数据 #9: Accepted, time = 0 ms, mem = 496 KiB, score = 10
Accepted, time = 6 ms, mem = 496 KiB, score = 100
代码#include <stdio.h>
int main()
{
int N, qimo, banji, lunwen, i = 0, I, moneyfinal = 0, moneytotal = 0;
long money;
char ganbu, xibu;
char name[30], namefinal[30];
scanf("%d", &N);
do
{
i = i + 1;
money = 0;
scanf("%s %d %d %c %c %d", &name, &qimo, &banji, &ganbu, &xibu, &lunwen);
if (((qimo > 80) && (lunwen != 0)) == 1) money = money + 8000;
else;
if (((qimo > 85) && (banji > 80)) == 1) money = money + 4000;
else;
if (qimo > 90) money = money + 2000;
else;
if (((qimo > 85) && (xibu == 'Y')) == 1) money = money + 1000;
else;
if (((banji > 80) && (ganbu == 'Y')) == 1) money = money + 850;
else;
moneytotal = moneytotal + money;
if (money > moneyfinal)
{
moneyfinal = money;
for (I = 0; I <= 30; I++) namefinal[I] = name[I];
}
else;
}
while (i < N);
printf("%s\n%d\n%d", namefinal, moneyfinal, moneytotal);
return 0;
} -
02015-10-26 17:15:51@
浪费时间。。。。。好吧很水
#include<stdio.h>
#include<string.h>
char s[25],z[25];
int main()
{
int n,i,a,b,e,qian=0,he=0,zong=0;
char c,d;
scanf("%d",&n);
scanf("%s%d%d %c %c%d",s,&a,&b,&c,&d,&e);
if (a>80&&e>=1) he+=8000;
if (a>85&&b>80) he+=4000;
if (a>90)he+=2000;
if (a>85&&d=='Y') he+=1000;
if (b>80&&c=='Y') he+=850;
strcpy(z,s);
qian=he;
zong=he;
he=0;
for (i=2;i<=n;i++)
{
scanf("%s%d%d %c %c%d",s,&a,&b,&c,&d,&e);
if (a>80&&e>=1) he+=8000;
if (a>85&&b>80) he+=4000;
if (a>90)he+=2000;
if (a>85&&d=='Y') he+=1000;
if (b>80&&c=='Y') he+=850;
if (he>qian)
{qian=he;
strcpy(z,s);}
zong+=he;
he=0;
}
printf("%s\n%d\n%d",z,qian,zong);
return 0;
} -
02015-10-25 14:08:13@
Free Pascal Compiler version 2.6.4 [2014/03/06] for i386
Copyright (c) 1993-2014 by Florian Klaempfl and others
Target OS: Win32 for i386
Compiling foo.pas
Linking foo.exe
85 lines compiled, 0.0 sec , 29472 bytes code, 1628 bytes data
测试数据 #0: Accepted, time = 0 ms, mem = 800 KiB, score = 10
测试数据 #1: Accepted, time = 0 ms, mem = 804 KiB, score = 10
测试数据 #2: Accepted, time = 0 ms, mem = 804 KiB, score = 10
测试数据 #3: Accepted, time = 0 ms, mem = 800 KiB, score = 10
测试数据 #4: Accepted, time = 4 ms, mem = 804 KiB, score = 10
测试数据 #5: Accepted, time = 0 ms, mem = 800 KiB, score = 10
测试数据 #6: Accepted, time = 0 ms, mem = 800 KiB, score = 10
测试数据 #7: Accepted, time = 4 ms, mem = 800 KiB, score = 10
测试数据 #8: Accepted, time = 0 ms, mem = 800 KiB, score = 10
测试数据 #9: Accepted, time = 0 ms, mem = 804 KiB, score = 10
Accepted, time = 8 ms, mem = 804 KiB, score = 100
代码
##
program p1001;
type t1=record
name:string;
qimo:0..100;
banji:0..100;
ganbu:boolean;
xibu:boolean;
lunwen:boolean;
end;
var a:array[1..100]of t1;
money:array[1..100]of longint;
kong:array[1..5]of longint;
str:string;
n,i,j,k,whole:longint;
function yuanshi(i:longint):boolean;
begin
if (a[i].qimo>80)and a[i].lunwen
then exit(true) else exit(false);
end;
function wusi(i:longint):boolean;
begin
if (a[i].qimo>85)and(a[i].banji>80)
then exit(true) else exit(false);
end;
function youxiu(i:longint):boolean;
begin
if (a[i].qimo>90)
then exit(true) else exit(false);
end;
function xibujiang(i:longint):boolean;
begin
if (a[i].qimo>85)and a[i].xibu
then exit(true) else exit(false);
end;
function banji(i:longint):boolean;
begin
if (a[i].banji>80)and a[i].ganbu
then exit(true) else exit(false);
end;
begin
readln(n);
for i:=1 to n do
begin
readln(str);
k:=0;
for j:=1 to length(str) do
if str[j]=' ' then
begin
inc(k);
kong[k]:=j;
end;
a[i].name:=copy(str,1,kong[1]-1);
val(copy(str,kong[1]+1,kong[2]-kong[1]-1),a[i].qimo,j);
val(copy(str,kong[2]+1,kong[3]-kong[2]-1),a[i].banji,j);
if str[kong[3]+1]='Y'
then a[i].ganbu:=true
else a[i].ganbu:=false;
if str[kong[4]+1]='Y'
then a[i].xibu:=true
else a[i].xibu:=false;
if str[kong[5]+1]='0'
then a[i].lunwen:=false
else a[i].lunwen:=true;
end;
fillchar(money,sizeof(money),0);
whole:=0;
for i:=1 to n do
begin
if yuanshi(i) then inc(money[i],8000);
if wusi(i) then inc(money[i],4000);
if youxiu(i) then inc(money[i],2000);
if xibujiang(i) then inc(money[i],1000);
if banji(i) then inc(money[i],850);
inc(whole,money[i]);
end;
j:=0;k:=0;
for i:=1 to n do
if j<money[i] then
begin
j:=money[i];
k:=i;
end;
writeln(a[k].name);
writeln(money[k]);
writeln(whole);
end. -
02015-10-12 21:40:28@
在vs上亲测可效,不过到了这边一直报错strcyp()没声明
#include<iostream>
#include<string>using namespace std;
int main()
{
int n, qm, bj, i;
int max = 0,total=0;
char yn1, yn2,Name[20],name[20];
cin >> n;
for (int j = 1; j <= n; j++)
{
int jxj = 0;
cin >> name >> qm >> bj >> yn1 >> yn2 >> i;
if (qm > 80 && i >= 1)
{
jxj = jxj + 8000;
}
if (qm > 85 && bj > 80)
{
jxj = jxj + 4000;
}
if (qm > 90)
{
jxj = jxj + 2000;
}
if (qm > 85 && yn2 == 'Y')
{
jxj = jxj + 1000;
}
if (bj > 80 && yn1 == 'Y')
{
jxj = jxj + 850;
}
total = total + jxj;
if (jxj > max)
{
max = jxj;
strcpy(Name, name);
}}
cout << Name << endl;
cout << max << endl;
cout<< total << endl;
return 0;
} -
02015-10-09 19:03:37@
简直水
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;string na[105];
char A,B;
bool gb[105],xb[105];
int lw[105],jf[105],pc[105],sum;
int n,i,jxj[105],pm[105],temp,j;int main()
{
cin>>n;
for (i=1;i<=n;i++)
{
cin>>na[i]>>jf[i]>>pc[i]>>A>>B>>lw[i];
if (A=='N') gb[i]=false;
else gb[i]=true;
if (B=='N') xb[i]=false;
else xb[i]=true;
pm[i]=i;
}
for (i=1;i<=n;i++)
{
if (jf[i]>80 && lw[i]>=1) jxj[i]+=8000; //院士奖学金
if (jf[i]>85 && pc[i]>80) jxj[i]+=4000; //五四奖学金
if (jf[i]>90) jxj[i]+=2000; //成绩优秀奖
if (jf[i]>85 && xb[i]) jxj[i]+=1000; //西部奖学金
if (pc[i]>80 && gb[i]) jxj[i]+=850; //班级贡献奖
sum+=jxj[i];
}
for (i=1;i<n;i++)
for (j=i+1;j<=n;j++)
{
if (jxj[i]<jxj[j]) {
temp=pm[i];pm[i]=pm[j];pm[j]=temp;
temp=jxj[i];jxj[i]=jxj[j];jxj[j]=temp;
}
if (jxj[i]==jxj[j] && pm[i]>pm[j]) {
temp=pm[i];pm[i]=pm[j];pm[j]=temp;
temp=jxj[i];jxj[i]=jxj[j];jxj[j]=temp;
}
}
cout<<na[pm[1]]<<endl<<jxj[1]<<endl<<sum<<endl;
} -
02015-09-12 12:53:40@
#include <cstdio>
#include <cstring>struct Person
{
char name[21];
int id;
int prize;
} person[100] = {"\0", 0, 0};int main(void)
{
char name[21] = "\0", job = '\0', west = '\0',
Mnam[21];
int i, n, final, score, article, prize, max = 0, total = 0;scanf("%d", &n);
for (i = 0; i < n; ++i)
{
scanf("%s %d %d %c %c %d", name, &final, &score, &job, &west, &article);
prize = 0;
if (final > 80)
{
if (article > 0)
{
prize += 8000;
}
if (final > 85)
{
if (score > 80)
{
prize += 4000;
}
if (final > 90)
{
prize += 2000;
}
if (west == 'Y')
{
prize += 1000;
}
}
}
if (score > 80 && job == 'Y')
{
prize += 850;
}
total += prize;
if ((!i) || prize > max)
{
strcpy(Mnam, name);
max = prize;
}
}
printf("%s\n%d\n%d", Mnam, max, total);
return 0;
} -
02015-09-12 10:35:44@
/login be8889f1
-
02015-07-20 11:48:35@
#include <iostream>
#include <string>
using namespace std;
int main(){
int a,b=0,c=0;
string d;
cin >> a;
while (a != 0){
string e, f, g;
int h, i, j, k;
cin >> e >> h >> i >> f >> g >> j;
k = (h > 80 && j >= 1 ? 8000 : 0) +
(h > 85 && i > 80 ? 4000 : 0) +
(h > 90 ? 2000 : 0) +
(h > 85 && g == "Y" ? 1000 : 0) +
(i > 80 && f == "Y" ? 850 : 0);
b += k;
if (k > c){
c = k;
d = e;
}
a--;
}
cout << d << endl;
cout << c << endl;
cout << b << endl;;
return 0;
} -
02015-07-20 11:44:25@
#include <iostream>
#include <string>
using namespace std;
int main(){
int 学生的总数,学金的总数=0,获得的奖金最多=0;
string 获得最多奖金的学生的姓名;
cin >> 学生的总数;
while (学生的总数 != 0){
string 姓名, 是否是学生干部, 是否是西部省份学生;
int 期末平均成绩, 班级评议成绩, 发表的论文数, 学金;
cin >> 姓名 >> 期末平均成绩 >> 班级评议成绩 >> 是否是学生干部 >> 是否是西部省份学生 >> 发表的论文数;
学金 = (期末平均成绩 > 80 && 发表的论文数 >= 1 ? 8000 : 0) +
(期末平均成绩 > 85 && 班级评议成绩 > 80 ? 4000 : 0) +
(期末平均成绩 > 90 ? 2000 : 0) +
(期末平均成绩 > 85 && 是否是西部省份学生 == "Y" ? 1000 : 0) +
(班级评议成绩 > 80 && 是否是学生干部 == "Y" ? 850 : 0);
学金的总数 += 学金;
if (学金 > 获得的奖金最多){
获得的奖金最多 = 学金;
获得最多奖金的学生的姓名 = 姓名;
}
学生的总数--;
}
cout << 获得最多奖金的学生的姓名 << endl;
cout << 获得的奖金最多 << endl;
cout << 学金的总数 << endl;
return 0;
} -
02015-07-19 08:30:54@
#include<stdio.h>
int main()
{
int n,i,j,all=0;
scanf("%d",&n);
struct student
{
char a[30],bg,xb;
int qm,by,lw,m;
}stu[n+10];
for(i=1;i<=n;i++)
{
scanf("%s %d %d %c %c %d",stu[i].a,&stu[i].qm,&stu[i].by,&stu[i].bg,&stu[i].xb,&stu[i].lw);
stu[i].m=0;
}
for(i=1;i<=n;i++)
{
if(stu[i].qm>80&&stu[i].lw>=1)
stu[i].m=stu[i].m+8000;
if(stu[i].qm>85&&stu[i].by>80)
stu[i].m=stu[i].m+4000;
if(stu[i].qm>90)
stu[i].m=stu[i].m+2000;
if(stu[i].qm>85&&stu[i].xb=='Y')
stu[i].m=stu[i].m+1000;
if(stu[i].by>80&&stu[i].bg=='Y')
stu[i].m=stu[i].m+850;
}
stu[0]=stu[1];
for(i=1;i<=n;i++)
{
if(stu[0].m<stu[i].m)
stu[0]=stu[i];
all=all+stu[i].m;
}
printf("%s\n%d\n%d",stu[0].a,stu[0].m,all);
return 0;
} -
02015-07-12 11:54:07@
#include"iostream"
#include<cstdio>
#include<cmath>
using namespace std;
typedef long long ll;
const int N=105;
struct node{
char name[21];
int endsc;
int classsc;
char ganbu;
char bibei;
int storys;
int award;
};
int n;
node stu[N];
ll ans;
int maxn=-1;
int k=-1;
void money(node &child,int i)
{
child.award=0;
if(child.endsc>80&&child.storys>=1)
child.award+=8000;
if(child.endsc>85&&child.classsc>80)
child.award+=4000;
if(child.endsc>90)
child.award+=2000;
if(child.endsc>85&&child.bibei=='Y')
child.award+=1000;
if(child.ganbu=='Y'&&child.classsc>80)
child.award+=850;
if(child.award>maxn)
{
maxn=child.award;
k=i;
}
ans+=child.award;
}
int main()
{
cin>>n;
for(int i=0;i<n;i++)
{
cin>>stu[i].name;
cin>>stu[i].endsc;
cin>>stu[i].classsc;
cin>>stu[i].ganbu;
cin>>stu[i].bibei;
cin>>stu[i].storys;
}
for(int i=0;i<n;i++)
money(stu[i],i);
cout<<stu[k].name<<endl;
cout<<maxn<<endl;
cout<<ans;return 0;
} -
02015-06-06 14:05:18@
测试数据 #0: Accepted, time = 0 ms, mem = 492 KiB, score = 10
测试数据 #1: Accepted, time = 0 ms, mem = 492 KiB, score = 10
测试数据 #2: Accepted, time = 1 ms, mem = 488 KiB, score = 10
测试数据 #3: Accepted, time = 0 ms, mem = 492 KiB, score = 10
测试数据 #4: Accepted, time = 0 ms, mem = 488 KiB, score = 10
测试数据 #5: Accepted, time = 0 ms, mem = 492 KiB, score = 10
测试数据 #6: Accepted, time = 0 ms, mem = 488 KiB, score = 10
测试数据 #7: Accepted, time = 15 ms, mem = 492 KiB, score = 10
测试数据 #8: Accepted, time = 2 ms, mem = 492 KiB, score = 10
测试数据 #9: Accepted, time = 0 ms, mem = 492 KiB, score = 10
#include <cstdio>
#include <cstring>
using namespace std;
int main(){
freopen("input.txt","r",stdin);
char s[100][20],c1,c2;
int n,sum=0,max=0,score1,score2,num,a,b,ans1;
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;ans1=i;}
}
printf("%s\n%d\n%d\n",s[ans1],max,sum);
return 0;
}刚学c++