511 条题解
-
0
tommyfj LV 4 @ 2022-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;
} -
02021-08-22 10:51:27@
#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;
} -
02021-08-10 21:50:02@
#include<bits/stdc++.h> using namespace std; int n,ALL; struct xs{ string name; int last_exam,class_decided; char is_worker,is_west; int photos,money,bh; }s[110]; bool cmp(xs a,xs b){ if(a.money!=b.money) return a.money>b.money; else if(a.bh!=b.bh) return a.bh<b.bh; } int main(){ cin>>n; for(int i=1;i<=n;i++){ s[i].money=0,s[i].bh=i; cin>>s[i].name; cin>>s[i].last_exam>>s[i].class_decided; cin>>s[i].is_worker>>s[i].is_west>>s[i].photos; if(s[i].last_exam>80 and s[i].photos>=1) s[i].money+=8000; if(s[i].last_exam>85 and s[i].class_decided>80) s[i].money+=4000; if(s[i].last_exam>90) s[i].money+=2000; if(s[i].last_exam>85 and s[i].is_west=='Y') s[i].money+=1000; if(s[i].class_decided>80 and s[i].is_worker=='Y') s[i].money+=850; ALL+=s[i].money; } sort(s+1,s+n+1,cmp); cout<<s[1].name<<"\n"<<s[1].money<<"\n"<<ALL; return 0; }
-
02021-08-03 21:29:17@
//AC代码,但做了点小改动
#include <bits/stdc++.h>
using namespace std;
long long n,q[200],b[200],l[200],pri,maxx,t,sum;
char g[200],x[200];
string s[200];
int mian(){
cin>>n;
for(int i=1;i<=n;i++)cin>>s[i]>>q[i]>>b[i]>>g[i]>>x[i]>>l[i];
for(int i=1;i<=n;i++)//几个判断自己xiangxiang
{
if(q[i]>80&&l[i]>=1)pri+=8000;
if(q[i]>85&&b[i]>80)pri+=4000;
if(q[i]>90)pri+=2000;
if(q[i]>85&&x[i]=='Y')pri+=1000;
if(b[i]>80&&g[i]=='Y')pri+=850;
sum+=pri;if(pri>maxx){maxx=pri;t=i;}pri=0;
}
cout<<s[t]<<endl<<maxx<<endl<<sum;
return 0;
} -
02021-07-15 14:16:15@
#include <iostream>
#include <vector>
using namespace std;
struct stu
{
string name, lead, west;
int fin, grade, paper;
int money = 0;
};
int main()
{
int n;
cin >> n;
vector<stu> stus(n);
int max = 0;
int where = 0;
int sum = 0;
for (int i = 0; i != n; i++)
{
cin >> stus[i].name >> stus[i].fin >> stus[i].grade >> stus[i].lead >> stus[i].west >> stus[i].paper;
if (stus[i].fin > 80 && stus[i].paper != 0){
stus[i].money += 8000;}
if (stus[i].fin > 85 && stus[i].grade > 80){
stus[i].money += 4000;}
if (stus[i].fin > 90){
stus[i].money += 2000;}
if (stus[i].fin > 85 && stus[i].west == "Y"){
stus[i].money += 1000;}
if (stus[i].grade > 80 && stus[i].lead == "Y"){
stus[i].money += 850;}
sum+=stus[i].money;
}
for (int i = 0; i != n; i++)
{
if (max < stus[i].money)
{
max = stus[i].money;
where = i;
}
}
cout << stus[where].name << endl
<< stus[where].money << endl
<< sum << endl;
} -
02021-06-12 08:37:00@
#include<iostream>
using namespace std;
struct STUDENT{
string name;
int n1,n2;
char xsgb,xb;
int lw;
int jxj;
};
int main(){
int n;
int sum=0;
cin>>n;
struct STUDENT stu[n];
struct STUDENT zdz;
zdz.jxj=0;
for(int i=0;i<n;i++)stu[i].jxj=0;
for(int i=0;i<n;i++){
cin>>stu[i].name>>stu[i].n1>>stu[i].n2>>stu[i].xsgb>>stu[i].xb>>stu[i].lw;
if(stu[i].n1>80&&stu[i].lw>=1)stu[i].jxj+=8000;
if(stu[i].n1>85&&stu[i].n2>80)stu[i].jxj+=4000;
if(stu[i].n1>90)stu[i].jxj+=2000;
if(stu[i].n1>85&&stu[i].xb=='Y')stu[i].jxj+=1000;
if(stu[i].n2>80&&stu[i].xsgb=='Y')stu[i].jxj+=850;
if(stu[i].jxj>zdz.jxj)zdz=stu[i];
sum+=stu[i].jxj;
}
cout<<zdz.name<<endl<<zdz.jxj<<endl<<sum;
return 0;}
-
02021-05-27 15:37:50@
#include<iostream>
#include<string>
using namespace std;int main()
{
int stdNum, averageScore, commentScore, papareNum;
string name,iscadre,iswest,maxName;
int allSum = 0, perSum = 0, maxSum = 0;
cin >> stdNum;
for (int i = 0; i < stdNum; i++)
{
cin >> name >> averageScore >> commentScore >> iscadre >> iswest >> papareNum;
if (papareNum>0&&averageScore>80) //院士奖学金
{
perSum += 8000;
}
if (averageScore>85&&commentScore>80) //五四奖学金
{
perSum += 4000;
}
if (averageScore>90) // 成绩优秀奖
{
perSum += 2000;
}
if (iswest=="Y"&&averageScore>85) // 西部奖学金
{
perSum += 1000;
}
if (iscadre=="Y"&&commentScore>80) // 班级贡献奖
{
perSum += 850;
}
if (perSum>maxSum)
{
maxSum = perSum;
maxName = name;
}
allSum += perSum;
perSum = 0;
}
cout << maxName << endl;
cout << maxSum << endl;
cout << allSum << endl;
return 0;
} -
02021-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); } }
-
02021-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;
} -
02021-02-16 15:06:39@
。
-
02021-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;
}
``` -
02020-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; }
-
02020-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; }
-
02020-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; }
-
02020-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的简单练手题
-
02020-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; }
谔谔
-
02020-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;
}
``` -
02020-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); }