本帖最后由 qwerthzrv 于 2021-2-21 17:36 编辑
大佬们帮忙看一下程序
在本机上运行样例成功,提交到网上(https://vijos.org/p/1001 )就没通过。。。
还有为啥我要定义结构类型struct data[total] 时,debugger时会弹出vs code会弹出无法打开cygwin.S。。
#include <stdio.h>
struct data {
char name[20]; //name
int aver; //average
int evo; //review of class
char lead; //is cadres or not
char west; //is west or not
int paper; //number of paper
int bonds; //bonds
};
int main(int argc,const char *argv[])
{
int total;
int sum,idx = 0;
scanf("%d", &total);
struct data m[100];
for (int i = 0; i < total;i++){
scanf("%s %d %d %c %c %d",m[i].name,&m[i].aver, &m[i].evo, &m[i].lead,&m[i].west, &m[i].paper);
m[i].bonds = 0;
if(m[i].aver > 80 && m[i].paper > 0) m[i].bonds +=8000;
if(m[i].aver > 85 && m[i].evo > 80) m[i].bonds += 4000;
if(m[i].aver > 90) m[i].bonds += 2000;
if(m[i].aver > 85 && m[i].west == 'Y') m[i].bonds += 1000;
if(m[i].evo > 80 && m[i].lead == 'Y') m[i].bonds += 850;
sum += m[i].bonds;
if(m[i].bonds > m[idx].bonds) idx = i;
}
printf("%s\n%d\n%d\n",m[idx].name,m[idx].bonds,sum);
return 0;
}
|