508 条题解
-
01 + 1 = 3 LV 6 @ 2024-10-04 09:27:56
#include <bits/stdc++.h>
using namespace std;
int n,qm,yh,lw,num,sum,ans = -9999999;
string name,ansname;
char gb,xi;
int main(){
cin >> n;
for(int i = 1;i <= n;i++){
num = 0;
cin >> name >> qm >> yh >> gb >> xi >> lw;
if(qm > 80 && lw > 0){
num += 8000;
}
if(qm > 85 && yh > 80){
num += 4000;
}
if(qm > 90){
num += 2000;
}
if(qm > 85 && xi == 'Y'){
num += 1000;
}
if(yh > 80 && gb == 'Y'){
num += 850;
}
sum += num;
if(num > ans){
ans = num;
ansname = name;
}
}
cout << ansname << endl << ans << endl << sum;
return 0;
} -
02024-08-05 11:35:16@
#include<bits/stdc++.h>//万能头文件
using namespace std;//命名空间
struct Item{//用结构体来储存输入的各项数据
string name;//储存姓名
int qc,bc;//qc表示期末平均成绩,bc表示班级评议成绩
char oxg,oxs;//oxg表示是否是学生干部,oxs表示是否是西部省份学生
int l,j;//l表示发表的论文数,j用来储存该学生获得的奖学金
}s[1000000];//开的大一点qaq
int main(){
int n,sum=0,ans1=0;//n表示学生的总数,sum用来储存这n个学生获得的奖学金的总数,ans1用来储存获得最多奖学金的学生的奖金总数
string ans2="";//ans2用来储存获得最多奖金的学生的姓名
cin>>n;//输入人数
for(int i=1;i<=n;i++){//依次输入
cin>>s[i].name>>s[i].qc>>s[i].bc>>s[i].oxg>>s[i].oxs>>s[i].l;//依次输入姓名,期末平均成绩,班级评议成绩,是否是学生干部,是否是西部省份学生,以及发表的论文数
//边输入边判断,效率可以更快一些
if(s[i].qc>80&&s[i].l>=1)s[i].j+=8000;//如果这位学生期末平均成绩>80并且发表的论文数>=1,获得"院士奖学金",奖金增加8000元
if(s[i].qc>85&&s[i].bc>80)s[i].j+=4000;//如果这位学生期末平均成绩>85并且班级评议成绩>80,获得"五四奖学金",奖金增加4000元
if(s[i].qc>90)s[i].j+=2000;//如果这位学生期末平均成绩>90,获得"成绩优秀奖",奖金增加2000元
if(s[i].qc>85&&s[i].oxs=='Y')s[i].j+=1000;//如果这位学生期末平均成绩>85并且是西部省份的学生,获得"西部奖学金",奖金增加1000元
if(s[i].bc>80&&s[i].oxg=='Y')s[i].j+=850;//如果这位学生班级评议成绩>80并且是学生干部,获得"班级贡献奖",奖金增加850元
if(s[i].j>ans1){//如果这位同学获得的奖学金>上一次记录的奖学金数,更新记录,且更新姓名
ans1=s[i].j;//更新记录
ans2=s[i].name;//且更新姓名
}
sum+=s[i].j;//总奖学金+=这位同学获得的奖学金
}
cout<<ans2<<endl<<ans1<<endl<<sum;//依次输出获得最多奖金的学生的姓名,这名学生获得的奖金总数,以及这N个学生获得的奖学金的总数
return 0;//提交后你会发现Accepted通过~(= ̄ω ̄=)
}
注:本人第一次发题解,可能不是最简短,效率最高的,但一定是最详细的,希望这篇题解对你有所帮助 -
02024-02-19 21:39:02@
一道考验C++判断语句的淼题
cpp
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
using namespace std;
const int N=1e4;
//N固定值为10的4次方
int a[N],b[N],c[N],ans[N]={0};
//a[N]表示期末平均成绩,b[N]表示班级评议成绩,c[N]表示发表的论文数量,ans[N]表示每个人的奖学金
char chr[N],c1[N],c2[N];
//chr[N]表示人名,c1[N]用于判断是否是班干部,c2[N]用于判断是不是西部学生
int maxx=-1,n,sum=0;
//maxx赋一个负数值便于找最大奖学金,sum用于计算奖学金的总数
string s;
//s用来记录获得奖学金最多的人的名字
int main()
{
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>chr>>a[i]>>b[i]>>c1[i]>>c2[i]>>c[i];
if(a[i]>80&&c[i]>=1)
{
ans[i]+=8000;
}
if(a[i]>85&&b[i]>80)
{
ans[i]+=4000;
}
if(a[i]>90)
{
ans[i]+=2000;
}
if(a[i]>85&&c2[i]=='Y')
{
ans[i]+=1000;
}
if(b[i]>80&&c1[i]=='Y')
{
ans[i]+=850;
}
sum+=ans[i];
if(ans[i]>maxx)
{
maxx=ans[i];
s=chr;
}
}
cout<<s<<endl<<maxx<<endl<<sum<<endl;
return 0;
}
-
02023-11-04 16:59:09@
感谢大佬分享懂了
#include<iostream>
using namespace std;
int main()
{
string a,g;
int b,c,f,n,money=0,result=0,sum=0;
char d,e;
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>a>>b>>c>>d>>e>>f;
money=0;
if(b>80&&f>=1)
money+=8000;
if(b>85&&c>80)
money+=4000;
if(b>90)
money+=2000;
if(b>85&&e=='Y')
money+=1000;
if(c>80&&d=='Y')
money+=850;
sum+=money;
if(result<money)
{
result=money;
g=a;
}
}
cout<<g<<endl<<result<<endl<<sum<<endl;
return 0; -
02023-10-29 17:30:12@
#include <bits/stdc++.h> using namespace std; struct student { string name; // 姓名 int a, b; // 期末平均成绩 班级评议成绩 char c, d; // 是否是学生干部 是否是西部省份学生 int e; // 发表的论文数 } t[105]; int main() { int n, sum = 0, x = 0, maxx = 0; string mz; cin >> n; for(int i = 1; i <= n; i++) cin >> t[i].name >> t[i].a >> t[i].b >> t[i].c >> t[i].d >> t[i].e; for(int i = 1; i <= n; i++) { x = 0; if(t[i].a > 80 && t[i].e >= 1) x += 8000; if(t[i].a > 85 && t[i].b > 80) x += 4000; if(t[i].a > 90) x += 2000; if(t[i].a > 85 && t[i].d == 'Y') x += 1000; if(t[i].b > 80 && t[i].c == 'Y') x += 850; sum += x; if(x > maxx) { maxx = x; mz = t[i].name; } } cout << mz << endl << maxx << endl << sum; return 0; }
-
02023-10-17 20:43:26@
#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 = 0; } cout << maxn << endl << max << endl << total; return 0; }
-
02023-10-07 23:27:11@
/******************************************************** 备注: ********************************************************/ #include <iostream> #include <iomanip> #include <cmath> #include <cstring> #include <algorithm> #include <cstdio> using namespace std; #define LL long long #define MAXM 3010 #define MAXN 3010 const int N =1e5+10; const int INF =0x3f3f3f3f; int main () { int a,b; cin>>a>>b; cout<<a+b; return 0; }
-
02023-09-15 18:02:27@
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
string name,maxName;
int exam,review,paper,bonus=0,maxBonus=0,sumBonus=0;
char cadres,west;
for (int i=1;i<=n;i++){
cin>>name>>exam>>review>>cadres>>west>>paper;
if (exam>80&&paper>=1){
bonus+=8000;
}
if (exam>85&&review>80){
bonus+=4000;
}
if (exam>90){
bonus+=2000;
}
if (exam>85&&west=='Y'){
bonus+=1000;
}
if (review>80&&cadres=='Y'){
bonus+=850;
}
if (bonus>maxBonus){
maxBonus=bonus;
maxName=name;
}
sumBonus+=bonus;
bonus=0;
}
cout<<maxName<<endl<<maxBonus<<endl<<sumBonus<<endl;
return 0;
} -
02023-07-03 20:41:08@
#include<iostream> using namespace std; int main(){ struct student{ string xm; long long int qm,py,lw,ans=0,xh; char gb,xb; }a[101]; long long int n,max1=0,max2=0; string zname; cin>>n; for(int i=1;i<=n;i++){ cin>>a[i].xm>>a[i].qm>>a[i].py>>a[i].gb>>a[i].xb>>a[i].lw; a[i].xh=i; if((a[i].qm>80)&&(a[i].lw>=1)) a[i].ans+=8000; if((a[i].qm>85)&&(a[i].py>80)) a[i].ans+=4000; if(a[i].qm>90) a[i].ans+=2000; if((a[i].qm>85)&&(a[i].xb=='Y')) a[i].ans+=1000; if((a[i].py>80)&&(a[i].gb=='Y')) a[i].ans+=850; max2+=a[i].ans; if(a[i].ans>max1){ zname=a[i].xm; max1=a[i].ans; } } cout<<zname<<endl<<max1<<endl<<max2; return 0; }
-
02023-07-02 23:04:22@
#include<bits/stdc++.h> using namespace std; const int MAXN=1e5+1; int read(){ int ans = 0, f = 1; char ch=getchar(); while(!isdigit(ch)) f*=(ch=='-')?-1:1,ch=getchar(); do ans=(ans<<1)+(ans<<3)+(ch^48),ch=getchar(); while(isdigit(ch)); return ans*f; } struct node{ string name; int grade1;//平均 int grade2;//评议 char gan; char west; int book; int all; int num; }a[MAXN]; bool cmp(node x,node y){ if(x.all==y.all)return x.num<y.num; return x.all>y.all; } int main(){ int n=read(); for(int i=1;i<=n;i++){ cin>>a[i].name>>a[i].grade1 >>a[i].grade2 >>a[i].gan >>a[i].west >>a[i].book; a[i].num=i; } for(int i=1;i<=n;i++){ if(a[i].grade1>80&&a[i].book>=1)a[i].all+=8000; if(a[i].grade1>85&&a[i].grade2>80)a[i].all+=4000; if(a[i].grade1>90)a[i].all+=2000; if(a[i].west=='Y'&&a[i].grade1>85)a[i].all+=1000; if(a[i].grade2>80&&a[i].gan=='Y')a[i].all+=850; } sort(a+1,a+n+1,cmp); cout<<a[1].name<<endl; cout<<a[1].all<<endl; int alll=0; for(int i=1;i<=n;i++)alll+=a[i].all; cout<<alll; return 0; } /*4 YaoLin 87 82 Y N 0 ChenRuiyi 88 78 N Y 1 LiXin 92 88 N N 0 ZhangQin 83 87 Y N 1*/
-
02023-05-14 21:14:06@
#include<bits/stdc++.h>
using namespace std;
const int MAXN=1e5+1;
int read(){
int ans = 0, f = 1;
char ch=getchar();
while(!isdigit(ch))
f*=(ch=='-')?-1:1,ch=getchar();
do ans=(ans<<1)+(ans<<3)+(ch^48),ch=getchar();
while(isdigit(ch));
return ans*f;
}
struct node{
string name;
int grade1;//平均
int grade2;//评议
char gan;
char west;
int book;
int all;
int num;
}a[MAXN];
bool cmp(node x,node y){
if(x.all==y.all)return x.num<y.num;
return x.all>y.all;
}
int main(){
int n=read();
for(int i=1;i<=n;i++){
cin>>a[i].name>>a[i].grade1 >>a[i].grade2 >>a[i].gan >>a[i].west >>a[i].book;
a[i].num=i;
}
for(int i=1;i<=n;i++){
if(a[i].grade1>80&&a[i].book>=1)a[i].all+=8000;
if(a[i].grade1>85&&a[i].grade2>80)a[i].all+=4000;
if(a[i].grade1>90)a[i].all+=2000;
if(a[i].west=='Y'&&a[i].grade1>85)a[i].all+=1000;
if(a[i].grade2>80&&a[i].gan=='Y')a[i].all+=850;
}
sort(a+1,a+n+1,cmp);
cout<<a[1].name<<endl;
cout<<a[1].all<<endl;
int alll=0;
for(int i=1;i<=n;i++)alll+=a[i].all;
cout<<alll;
return 0;
} -
02022-09-16 13:35:11@
注意点:scanf格式符间加空格
#include <stdio.h> int main(void) { struct student { char name[20]; int finalScore; int commentScore; char stuLeader; char westernProvince; int paper; int sumAward; }; int sumNum = 0; scanf("%d", &sumNum); struct student STUDENT[sumNum]; for(int i = 0; i < sumNum; i++) { STUDENT[i].sumAward = 0; scanf("%s %d %d %c %c %d", STUDENT[i].name, &STUDENT[i].finalScore, &STUDENT[i].commentScore, &STUDENT[i].stuLeader, &STUDENT[i].westernProvince, &STUDENT[i].paper); if( (STUDENT[i].finalScore > 80) && (STUDENT[i].paper > 0) ) { STUDENT[i].sumAward += 8000; } if( (STUDENT[i].finalScore > 85) && (STUDENT[i].commentScore> 80) ) { STUDENT[i].sumAward += 4000; } if(STUDENT[i].finalScore > 90) { STUDENT[i].sumAward += 2000; } if( (STUDENT[i].finalScore > 85) && (STUDENT[i].westernProvince == 'Y') ) { STUDENT[i].sumAward += 1000; } if( (STUDENT[i].commentScore > 80) && (STUDENT[i].stuLeader == 'Y') ) { STUDENT[i].sumAward += 850; } } int index = 0; int stuSumAward = 0; for(int j = 0; j < sumNum; j++) { if(STUDENT[index].sumAward < STUDENT[j].sumAward) { index = j; } stuSumAward += STUDENT[j].sumAward; } printf("%s\n%d\n%d", STUDENT[index].name, STUDENT[index].sumAward, stuSumAward); return 0; }
-
02022-09-04 15:42:27@
1
-
02022-08-28 21:11:10@
#include<bits/stdc++.h>
using namespace std;
int main()
{
int c;
cin>>c;
string name[c];
char n,m;
int x,y,z,money[c],max_money=0,s_money=0;
memset(money,0,sizeof(money));
for(int i=0;i<c;i++)
{
cin>>name[i]>>x>>y>>n>>m>>z;
if(x>80&&z>=1)money[i]+=8000;
if(x>85&&y>80)money[i]+=4000;
if(x>90)money[i]+=2000;
if(x>85&&m=='Y')money[i]+=1000;
if(y>80&&n=='Y')money[i]+=850;
if(money[i]>max_money)
max_money=money[i];
s_money+=money[i];
}
for(int i=0;i<c;i++)
if(max_money==money[i])
{
cout<<name[i]<<endl<<max_money<<endl<<s_money<<endl;
break;
}
return 0;
} -
02022-07-24 12:11:33@
这是一道较为简单的模拟题
#include<bits/stdc++.h> using namespace std; int n; struct obj{//定义结构体,方便作答 string name;//名字 int K_pj,B_pj;//考试成绩和评议成绩 char b,x;//是否是学生干部和西部省份学生 int lw;//论文 int xh;//序号(文件的顺序) int sum;//奖金总和 }arr[109]; bool cmp(obj a, obj b){//比较函数 if(a.sum>b.sum){ //奖金多的在前 return true; }else if(a.sum==b.sum){ //如果奖金一样 if(a.xh<b.xh) return true; //序号小的在前 } return false; } int main(){ cin>>n; for(int i=1;i<=n;i++){ cin>>arr[i].name>>arr[i].K_pj>>arr[i].B_pj>>arr[i].b>>arr[i].x>>arr[i].lw; arr[i].xh=i;//序号赋值 } long long Z_sum=0;//所有人的奖金值 for(int i=1;i<=n;i++){ if(arr[i].K_pj>80 && arr[i].lw>=1) arr[i].sum+=8000;//院士奖 if(arr[i].K_pj>85 && arr[i].B_pj>80) arr[i].sum+=4000;//五四奖 if(arr[i].K_pj>90) arr[i].sum+=2000;//成绩奖 if(arr[i].K_pj>85 && arr[i].x=='Y') arr[i].sum+=1000;//西部奖 if(arr[i].B_pj>80 && arr[i].b=='Y') arr[i].sum+=850;//贡献奖 Z_sum+=arr[i].sum; } sort(arr+1,arr+1+n,cmp); cout<<arr[1].name<<endl;//奖金最多的人的名字 cout<<arr[1].sum<<endl;//他的奖金数 cout<<Z_sum;//总奖金 return 0;//完美撒花 }
-
02022-07-16 22:28:34@
\(\rule{10000000mm}{100000000mm}\)
-
02022-06-24 20:58:04@
#include<iostream>
using namespace std;
int main(){
string a,name;
int b,c,f,n,money=0,max=0,sum=0;
char d,e;
cin>>n;
for(int i=1;i<=n;i++){
cin>>a>>b>>c>>d>>e>>f;
money=0;
if(b>80 && f>=1){
money+=8000;
}
if(b>85 && c>80){
money+=4000;
}
if(b>90){
money+=2000;
}
if(b>85 && e=='Y'){
money+=1000;
}
if(c>80 && d=='Y'){
money+=850;
}
if(max<money){
max=money;
name=a;
}
sum+=money;
}
cout<<name<<endl<<max<<endl<<sum<<endl;
return 0;
} -
02022-06-23 17:33:21@
#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 = 0; } cout << maxn << endl << max << endl << total; return 0; }
-
02022-04-09 15:31:45@
#include <stdio.h> #include <stdlib.h> #define N 10 typedef struct winners { char name[20]; int finalScore; int classScore; char work; char west; int paper; int scholarship; } WIN; void Addup(WIN stu[], int n); int FindMax(WIN student[], int n); int main() { int i, n, max; printf("Input n:"); scanf("%d",&n); WIN stu[N]; for (i=0;i<n;i++) { printf("Input name:"); scanf("%s",stu[i].name); printf("Input final score:"); scanf("%d",&stu[i].finalScore); printf("Input class score:"); scanf("%d",&stu[i].classScore); printf("Class cadre or not?(Y/N):"); scanf(" %c",&stu[i].work); printf("Students from the West or not?(Y/N):"); scanf(" %c",&stu[i].west); printf("Input the number of published papers:"); scanf("%d",&stu[i].paper); Addup(stu, i); } max = FindMax(stu, n); printf("%s get the highest scholarship %d\n",stu[max].name,stu[max].scholarship); return 0; } void Addup(WIN stu[], int n) { stu[n].scholarship = 0; if (stu[n].finalScore > 80 && stu[n].paper >= 1) stu[n].scholarship += 8000; if (stu[n].finalScore > 85 && stu[n].classScore > 80) stu[n].scholarship += 4000; if (stu[n].finalScore > 90) stu[n].scholarship += 2000; if (stu[n].finalScore > 85 && stu[n].west == 'Y') stu[n].scholarship += 1000; if (stu[n].classScore >80 && stu[n].work == 'Y') stu[n].scholarship += 850; printf("name:%s,scholarship:%d\n",stu[n].name,stu[n].scholarship); } int FindMax(WIN student[], int n) { int max = 0; for (int i=1;i<n;i++) { if (student[max].scholarship < student[i].scholarship) max = i; } return max; }
-
02021-08-22 10:54:33@
使用c++的类很简单就用过了,主要注意字符串的处理,直接建立一个学生的类别
一次ac!!,庆祝我的第一个c++程序
#include<iostream>
using namespace std;class CStu
{
public:
string name[100];
int score;
int classscore;
char student;
char position;
int number;
int prize;
CStu()
{
prize = 0;
}
};
int main()
{
int a=0;
int max = 0;
CStu stu[100];
cin >> a;
int total=0;
for (int i = 0; i < a; i++)
{
cin >> stu[i].name[50];
cin >> stu[i].score;
cin >> stu[i].classscore;
cin >> stu[i].student;
cin >> stu[i].position;
cin >> stu[i].number;
}
for (int b = 0; b < a; b++)
{
if ((stu[b].score > 80) && (stu[b].number >= 1))
{
stu[b].prize = stu[b].prize + 8000;
}//院士奖学金
if ((stu[b].score > 85) && (stu[b].classscore > 80))
{
stu[b].prize = stu[b].prize + 4000;
}//五四奖学金
if (stu[b].score > 90)
{
stu[b].prize = stu[b].prize + 2000;
}//成绩优秀奖学金
if ((stu[b].score > 85) && (stu[b].position == 'Y'))
{
stu[b].prize = stu[b].prize + 1000;
}//西部奖学金
if ((stu[b].classscore > 80) && (stu[b].student == 'Y'))
{
stu[b].prize = stu[b].prize + 850;
}//班级贡献奖学金
}
max = stu[0].prize;
total = 0;
for (int i = 0; i < a; i++)
{
if (max < stu[i ].prize)
{
max = stu[i].prize;
}
total = total + stu[i ].prize;
}
for (int i = 0; i < a; i++){
if (stu[i].prize == max)
{
cout << stu[i].name[50] << endl;
break;
}
}
cout << max << endl << total << endl;
return 0;
}