522 条题解
-
0
wu767439815 LV 5 @ 2021-05-18 10:45:23
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Scanner; /** * @author wpx * @version V1.0 * @Package com.algorithm * @date 2021/5/18 10:08 */ public class Main { public static void main(String[] args) { Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(System.in))); int studentNum = Integer.valueOf(sc.nextLine()); int allTotalScore = 0; int maxScore = 0; String studentName = ""; for(int i = 0; i < studentNum; i++){ final String[] infos = sc.nextLine().split(" "); int avgScore = Integer.valueOf(infos[1]); int classScore = Integer.valueOf(infos[2]); boolean isStudentCadres = "Y".equals(infos[3]) ? true : false; boolean isWestStudent = "Y".equals(infos[4]) ? true : false; int paperNum = Integer.valueOf(infos[5]); // 计算总分 int totalScore = 0; if(avgScore > 80 && paperNum >= 1) { // 院士奖学金,每人8000元,期末平均成绩高于80分(>80),并且在本学期内发表1篇或1篇以上论文的学生均可获得; totalScore += 8000; } if(avgScore > 85 && classScore > 80) { // 五四奖学金,每人4000元,期末平均成绩高于85分(>85),并且班级评议成绩高于80分(>80)的学生均可获得 totalScore += 4000; } if(avgScore > 90) { // 成绩优秀奖,每人2000元,期末平均成绩高于90分(>90)的学生均可获得; totalScore += 2000; } if(avgScore > 85 && isWestStudent){ // 西部奖学金,每人1000元,期末平均成绩高于85分(>85)的西部省份学生均可获得; totalScore += 1000; } if(classScore > 80 && isStudentCadres){ //班级贡献奖,每人850元,班级评议成绩高于80分(>80)的学生干部均可获得 totalScore += 850; } if(totalScore > maxScore){ studentName = infos[0]; maxScore = totalScore; } allTotalScore += totalScore; } System.out.println(studentName); System.out.println(maxScore); System.out.println(allTotalScore); } } -
0@ 2021-02-24 18:47:56
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,score1,score2,sum=0,max=0,total=0,x,i;
char a,b;
string name,maxn;
cin>>n;
for(i=1;i<=n;i++)
{
cin>>name>>score1>>score2>>a>>b>>x;
if(score1>80 && x>0)//判断是否获得院士奖学金
sum+=8000;
if(score1>85 && score2>80)//判断是否获得五四奖学金
sum+=4000;
if(score1>90)//判断是否获得成绩优秀奖
sum+=2000;
if(score1>85 && b=='Y')//判断是否获得西部奖学金
sum+=1000;
if(score2>80 && a=='Y')//判断是否获得班级贡献奖
sum+=850;
total+=sum;//累加奖学金
if(sum>max)//找出最牛学生
maxn=name,max=sum;//sum的用处
sum=0;
}
cout<<maxn<<endl<<max<<endl<<total;
return 0;
} -
0@ 2021-02-16 15:06:39
。
-
0@ 2021-01-14 16:19:58
简单的结构体问题
```c
#include <stdio.h>
struct student
{
char name[30];
int score1;
int score2;
char y1;
char y2;
int num;
}st[120];
int main()
{
int n=0;
scanf("%d",&n);
int max=0,all=0;
int who;
for(int i=0;i<n;i++)
{
scanf("%s %d %d %c %c %d",&st[i].name,&st[i].score1,&st[i].score2,&st[i].y1,&st[i].y2,&st[i].num);
int prize=0;
if (st[i].score1>80&&st[i].num>0)
prize+=8000;
if (st[i].score1>85&&st[i].score2>80)
prize+=4000;
if (st[i].score1>90)
prize+=2000;
if (st[i].score1>85&&st[i].y2=='Y')
prize+=1000;
if (st[i].score2>80&&st[i].y1=='Y')
prize+=850;if (prize>max)
{
max=prize;
who=i;
}
all+=prize;
}
printf("%s\n%d\n%d",st[who].name,max,all);
return 0;
}
``` -
0@ 2020-09-16 21:30:02
#include<cstdio> #include<iostream> #include<algorithm> using namespace std; struct Student { string name; int id,aver,comm,acti,total; bool west,stu; }student[105]; int cmp(Student a,Student b) { if(a.total==b.total) return a.id<b.id; return a.total>b.total; } int main() { int n; cin>>n; for(int i=1;i<=n;i++) { char isWest,isStu; cin>>student[i].name>>student[i].aver>>student[i].comm>>isStu>>isWest>>student[i].acti; student[i].stu=(isStu=='Y')?true:false; student[i].west=(isWest=='Y')?true:false; student[i].id=i; } int res=0; for(int i=1;i<=n;i++) { if(student[i].aver>80&&student[i].acti>=1) student[i].total+=8000,res+=8000; else; if(student[i].aver>85&&student[i].comm>80) student[i].total+=4000,res+=4000; else; if(student[i].aver>90) student[i].total+=2000,res+=2000; else; if(student[i].aver>85&&student[i].west) student[i].total+=1000,res+=1000; else; if(student[i].comm>80&&student[i].stu) student[i].total+=850,res+=850; else; } sort(student+1,student+1+n,cmp); cout<<student[1].name<<endl<<student[1].total<<endl<<res<<endl; return 0; } -
0@ 2020-08-21 11:10:26
#include<bits/stdc++.h> using namespace std; struct student { string name; int qm; int py; char mas; char wes; int lw; int mai; }; student a[1001]; int main() { int n; int addmai=0; int k=0; int maxmai=-100; cin>>n; for(int i=0; i<n; i++) { cin>>a[i].name; cin>>a[i].qm>>a[i].py; cin>>a[i].mas>>a[i].wes; cin>>a[i].lw; } for(int i=0; i<n; i++) { if(a[i].qm>80&&a[i].lw>=1)a[i].mai+=8000; if(a[i].qm>85&&a[i].py>80)a[i].mai+=4000; if(a[i].qm>90)a[i].mai+=2000; if(a[i].qm>85&&a[i].wes=='Y')a[i].mai+=1000; if(a[i].py>80&&a[i].mas=='Y')a[i].mai+=850; addmai+=a[i].mai; if(maxmai!=a[i].mai) { maxmai=max(maxmai,a[i].mai); if(maxmai==a[i].mai)k=i; } } cout<<a[k].name<<endl<<maxmai<<endl<<addmai<<endl; return 0; } -
0@ 2020-07-09 22:03:09
#include<bits/stdc++.h> using namespace std; int main() { int n,cj1,cj2,sum=0,max=0,s=0,x,i; char a,b; string ne,maxx; cin>>n; for(i=1;i<=n;i++) { cin>>ne>>cj1>>cj2>>a>>b>>x; if(cj1>80 && x>0) sum+=8000; if(cj1>85 && cj2>80) sum+=4000; if(cj1>90) sum+=2000; if(cj1>85 && b=='Y') sum+=1000; if(cj2>80 && a=='Y') sum+=850; s+=sum; if(sum>max) maxx=ne,max=sum; sum=0; } cout<<maxx<<endl<<max<<endl<<s; return 0; } -
0@ 2020-06-03 16:54:16
#include<iostream> #include<algorithm> #include<cstring> using namespace std; const int N = 100; struct Student { string name; int p; int y; char x; char g; int paper; int money; }; Student cls[N+1]; int main() { int n,am = 0; cin >> n; for(int i=0;i<n;i++) { cin >> cls[i].name; cin >> cls[i].p; cin >> cls[i].y; cin >> cls[i].g; cin >> cls[i].x; cin >> cls[i].paper; } for(int i=0;i<n;i++) { if(cls[i].p>80&&cls[i].paper>=1) { cls[i].money+=8000; } if(cls[i].p>85&&cls[i].y>80) { cls[i].money+=4000; } if(cls[i].p>90) { cls[i].money+=2000; } if(cls[i].p>85&&cls[i].x=='Y') { cls[i].money+=1000; } if(cls[i].y>80&&cls[i].g=='Y') { cls[i].money+=850; } } int Max=0; string Name; for(int i=0;i<n;i++) { if(Max<cls[i].money){ Max=cls[i].money; Name=cls[i].name; } am+=cls[i].money; } cout << Name << endl; cout << Max << endl; cout << am; return 0; }结构体和if的简单练手题
-
0@ 2020-05-31 10:23:09
#include<bits/stdc++.h> using namespace std; int main() { int n,m,em,sum=0,max=0,total=0,x,i; char a,b; string name,dalao; cin>>n; for(i=1;i<=n;i++){ cin>>name>>m>>em>>a>>b>>x; if(m>80 && x>0){ sum+=8000; } if(m>85 && em>80){ sum+=4000; } if(m>90){ sum+=2000; } if(m>85 && b=='Y'){ sum+=1000; } if(em>80 && a=='Y'){ sum+=850; } total+=sum; if(sum>max){ dalao=name,max=sum; } sum=0; } cout<<dalao<<endl; cout<<max<<endl; cout<<total; }谔谔
-
0@ 2020-05-09 13:50:54
用结构体模拟即可
cpp
#include<iostream>
#include<string>
using namespace std;
struct student{
string a;
int o,oo,ooo;
char on,ok;
}b[100];
main()
{
int n,tmp[100]={0},max=0,sum=0,k,a,ba;
cin>>n;
for(int i=0;i<n;i++)
{
cin>>b[i].a>>b[i].o>>b[i].oo>>b[i].on>>b[i].ok>>b[i].ooo;
if(b[i].o>80&&b[i].ooo) tmp[i]+=8000;
if(b[i].o>85&&b[i].oo>80) tmp[i]+=4000;
if(b[i].o>90) tmp[i]+=2000;
if(b[i].o>85&&b[i].ok=='Y') tmp[i]+=1000;
if(b[i].oo>80&&b[i].on=='Y') tmp[i]+=850;
sum+=tmp[i];
if(tmp[i]>max)
{
max=tmp[i];
k=i;
}
}
cout<<b[k].a<<endl<<max<<endl<<sum;
return 0;
}
``` -
0@ 2020-03-10 16:54:25
思路:暴力模拟,祝**AC**
#include <iostream> #include <cstring> using namespace std; int main() { /* 没用什么高级语法,写给新手 变量名解释 N(题目中N) 当前处理学生的:name(姓名),pj(平均成绩),bj(班级评议成绩), gb(干部?),xb(西部省份学生?),lw(论文数),jj(奖金数) 答案:zgjj(最高奖金),zgname(拿到最高奖金的学生姓名),zjj(总奖金) */ char name[21], zgname[21], gb, xb; int N, pj, bj, lw, jj, zjj = 0, zgjj = 0; scanf("%d", &N); for (int i = 0; i < N; ++i) { jj = 0; scanf("%s %d %d %c %c %d\n", name, &pj, &bj, &gb, &xb, &lw); //win下模拟输入时 Ctrl+z 输入 EOF if (pj > 80 && lw) jj += 8000; if (pj > 85 && bj > 80) jj += 4000; if (pj > 90) jj += 2000; if (pj > 85 && xb == 'Y') jj += 1000; if (bj > 80 && gb == 'Y') jj += 850; if (jj > zgjj) zgjj = jj, strcpy(zgname, name); zjj += jj; } printf("%s\n%d\n%d", zgname, zgjj, zjj); } -
0@ 2020-02-20 18:46:20
#include<iostream> #include<cmath> #include<string> #include<algorithm> using namespace std; int v[10001]; struct person { string name; int qm,sl,py; int cnt; char b,c; }; struct person a[10001]; int main() { int i,n,j; long long sum=0; cin>>n; for(i=1;i<=n;i++) { cin>>a[i].name>>a[i].qm>>a[i].py>>a[i].b>>a[i].c>>a[i].sl; v[i]=i; a[i].cnt=0; } for(i=1;i<=n;i++) { if(a[i].qm>80 and a[i].sl>=1) a[i].cnt+=8000; if(a[i].qm>85 and a[i].py>80) a[i].cnt+=4000; if(a[i].qm>90) a[i].cnt+=2000; if(a[i].qm>85 and a[i].c=='Y') a[i].cnt+=1000; if(a[i].py>80 and a[i].b=='Y') a[i].cnt+=850; } for(i=1;i<=n;i++) sum+=a[i].cnt; for(i=1;i<n;i++) { for(j=i+1;j<=n;j++) { if(a[i].cnt<a[j].cnt) swap(a[i],a[j]); if(a[i].cnt==a[j].cnt and v[i]>v[j]) swap(a[i],a[j]); } } cout<<a[1].name<<endl; cout<<a[1].cnt<<endl; cout<<sum; return 0; } -
0@ 2020-02-09 20:47:18
#include <stdio.h> #include <iostream> #include <algorithm> using namespace std; struct stu { int id; char name[100]; int qm,py; char gb,xb; int lw,jj; }a[110]; int jxj (int qm,int py,char gb,char xb,int lw) { int jj=0; if (qm>80&&lw>=1) jj+=8000; if (qm>85&&py>80) jj+=4000; if (qm>90) jj+=2000; if (qm>85&&xb=='Y') jj+=1000; if (py>80&&gb=='Y') jj+=850; return jj; } bool operator <(const stu &p1,const stu &p2) { if (p1.jj!=p2.jj) return p1.jj<p2.jj; return p1.id>p2.id; } int main () { int n,i,zq=0; scanf ("%d",&n); for (i=0;i<n;i++) { scanf ("%s%d%d %c %c%d", a[i].name,&a[i].qm,&a[i].py,&a[i].gb,&a[i].xb,&a[i].lw); a[i].jj=jxj(a[i].qm,a[i].py,a[i].gb,a[i].xb,a[i].lw); a[i].id=i+1; zq+=a[i].jj; } sort (a,a+n); printf ("%s\n",a[i-1].name); printf ("%d\n",a[i-1].jj); printf ("%d",zq); return 0; } -
0@ 2019-12-01 16:47:08
some_stu = [] money_max = 0 money_count = 0 money_name = '0' for i in range(int(input())): some_stu.append((input().split())) for item in some_stu: money = 0 money += 8000 if int(item[1]) > 80 and int(item[5]) >= 1 else 0 money += 4000 if int(item[1]) > 85 and int(item[2]) > 80 else 0 money += 2000 if int(item[1]) > 90 else 0 money += 1000 if int(item[1]) > 80 and item[4] == 'Y' else 0 money += 850 if int(item[2]) > 80 and item[3] == 'Y' else 0 money_count += money if money > money_max: money_name = item[0] money_max = money print(money_name) print(money_max) print(money_count)python 不知道错哪了
-
0@ 2019-11-20 22:13:19
这里用到了结构数组动态分配内存大家可以看看
#include<iostream>
#include<string>
#include<malloc.h>
#define LEN sizeof(struct Student)
using namespace std;
struct Student{
char name[100];
int gard_exam;
int gard_evaluate;
char student_leader[1];
int nums_paper;
char student_west[1];};
int main(){
int n;
cin >> n;
struct Student *stu=NULL;
stu = (struct Student *)malloc(sizeof(struct Student)*n);
for (int i = 0; i < n; i++){
cin >> stu[i].name >> stu[i].gard_exam >> stu[i].gard_evaluate >> stu[i].student_leader >> stu[i].student_west >> stu[i].nums_paper;
}
int sum_grad=0;
int max_grad = 0;
string name_cout;
for (int i = 0; i < n; i++){
int t_grad = 0;
if (stu[i].gard_exam > 80 && stu[i].nums_paper >= 1){
t_grad += 8000;
}
if (stu[i].gard_exam > 85 && stu[i].gard_evaluate > 80){
t_grad += 4000;
}
if (stu[i].gard_exam > 90){
t_grad += 2000;
}
if (stu[i].gard_exam > 85 && stu[i].student_west[0]=='Y'){
t_grad += 1000;
}
if (stu[i].gard_exam > 80 && stu[i].student_leader[0] == 'Y'){
t_grad += 850;
}
sum_grad = sum_grad+t_grad;
if (max_grad < t_grad){
max_grad = t_grad;
name_cout = stu[i].name;
}
}
cout << name_cout << endl;
cout << max_grad << endl;
cout << sum_grad << endl;
} -
0@ 2019-09-27 19:41:51
暴力模拟,大H2O题目
祝大家全AC#include<bits/stdc++.h> #define FOR(i,n,m) for(int i=n;i<=m;i++) using namespace std; struct student{ string name; int endtest,classtest,stu,west,lw,money; }a[105]; int n,allmoney,ans=0,now=0; int main() { char s,w; cin>>n; FOR(i,1,n) { cin>>a[i].name; cin>>a[i].endtest>>a[i].classtest; cin>>s>>w>>a[i].lw; if(s=='Y') a[i].stu=1; else a[i].stu=0;//是否是学生干部 if(w=='Y') a[i].west=1; else a[i].west=0;//是否是西部学生 //开始颁发奖学金 if(a[i].endtest>80&&a[i].lw>=1) a[i].money+=8000;//院士奖学金 if(a[i].endtest>85&&a[i].classtest>80) a[i].money+=4000;//五四奖学金 if(a[i].endtest>90) a[i].money+=2000;//成绩优秀奖 if(a[i].endtest>85&&a[i].west==1) a[i].money+=1000;//西部奖学金 if(a[i].classtest>80&&a[i].stu==1) a[i].money+=850;//班级贡献奖 allmoney+=a[i].money;//计算发出奖学金总和 if(now<a[i].money) { now=a[i].money; ans=i; }//查找奖学金最高者 } cout<<a[ans].name<<'\n'<<a[ans].money<<'\n'<<allmoney; return 0; } -
0@ 2019-08-18 15:02:51
分析一下思路:
1. 输入各类数据
2. 算出每个人的奖金数,注意,在算的时候要使用if-if,不能使用if-else if - else结构,因为每个人都可以领多个奖学金,所以有些人符合多个条件
3. 遍历数组,寻找最多奖学金,求出全部奖金和
4. 输出有最多奖学金的人,最多的奖学金,以及总共奖学金/* @createTime 2019.2.10 @Author C++语言学习者青云 @problemName 谁拿了最多奖学金 */ #include <iostream> using namespace std; int main() { int a; cin >> a; string name[a]; int score[a]; int pingyi[a]; char ganbu[a]; char xibu[a]; int lunwen[a]; int money[a]; int w = 0,maxmoney = 0,allmoney = 0; for(int i = 0;i < a;i++) { cin >> name[i] >> score[i] >> pingyi[i] >> ganbu[i] >> xibu[i] >> lunwen[i]; } for(int i = 0;i < a;i++) { money[i] = 0; if(score[i] > 80 && lunwen[i] >= 1) { money[i] += 8000; } if(score[i] > 85 && pingyi[i] > 80) { money[i] += 4000; } if(score[i]> 90) { money[i] += 2000; } if(score[i] > 85 && xibu[i] == 'Y') { money[i] += 1000; } if(pingyi[i] > 80 && ganbu[i] == 'Y') { money[i] += 850; } allmoney += money[i]; } for(int i = 0;i < a;i++) { if(maxmoney < money[i]) { maxmoney = money[i]; w = i; } } cout << name[w] << endl << maxmoney << endl << allmoney; return 0; }一道很不错的模拟题,祝大家全部AC
最后吐槽一句:这是什么学校?发这么多奖学金? -
0@ 2019-07-23 21:42:39
'''Python...'''
x = int(input())
tot = 0
top = 0
for i in range(x):
y = input().split()
mo = 0
mo += 8000 if int(y[1]) > 80 and int(y[5]) > 0 else 0
mo += 4000 if int(y[1]) > 85 and int(y[2]) > 80 else 0
mo += 2000 if int(y[1]) > 90 else 0
mo += 1000 if y[4] == 'Y' and int(y[1]) > 85 else 0
mo += 850 if int(y[2]) > 80 and y[3] == 'Y' else 0
tot += mo
if top < mo:
top = mo
name = y[0]
print(name)
print(top)
print(tot) -
0@ 2019-06-19 15:59:31
#include <iostream>
#include <string>
using namespace std;
struct student {
string name;
int cj1;
int cj2;
int write;
int money;
}per[100];
int main(void)
{
int all;
int i = 0;
int win = 0;
unsigned long int all_money = 0;
char a;
cin >> all;
while (i < all) {
per[i].money = 0;
cin >> per[i].name;
cin >> per[i].cj1;
cin >> per[i].cj2;
cin >> a;
if (a == 'Y'&&per[i].cj2 > 80)per[i].money += 850;
cin >> a;
if (a == 'Y'&&per[i].cj1 > 85)per[i].money += 1000;
cin >> per[i].write;
if (per[i].cj1 > 80 && per[i].write)per[i].money += 8000;
if (per[i].cj1 > 85 && per[i].cj2 > 80)per[i].money += 4000;
if (per[i].cj1 > 90)per[i].money += 2000;
++i;
}
for (i = 0; i < all; ++i) {
if (per[win].money < per[i].money)win = i;
all_money += per[i].money;
}
cout << per[win].name << endl << per[win].money << endl << all_money;
return 0;
} -
0@ 2019-06-12 20:38:10
按题意判断即可~
cpp
#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;
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;
}