508 条题解

  • 0
    @ 2014-03-23 16:30:40

    #include <cstdlib>
    #include <iostream>
    #include <math.h>
    #include <time.h>
    #include <string.h>

    using namespace std;

    struct geren{
    char name[32];
    int qm;
    int bj;
    char gb;
    char xb;
    int lw;
    int sum;
    int sh;
    };

    geren a[101];

    int main(int argc,char *argv[])
    {
    int i,j,k,n,m;
    cin>>n;
    for(i=0;i<n;i++)
    {
    cin>>a[i].name>>a[i].qm>>a[i].bj>>a[i].gb>>a[i].xb>>a[i].lw;
    a[i].sum=0;
    a[i].sh=i;
    }
    k=0;
    for(i=0;i<n;i++)
    {
    if(a[i].qm>80 && a[i].lw>0)
    {
    a[i].sum+=8000;
    k+=8000;
    }
    if(a[i].qm>85 && a[i].bj>80)
    {
    a[i].sum+=4000;
    k+=4000;
    }
    if(a[i].qm>90)
    {

    a[i].sum+=2000;
    k+=2000;
    }
    if(a[i].qm>85 && a[i].xb=='Y')
    {
    a[i].sum+=1000;
    k+=1000;
    }
    if(a[i].bj>80 && a[i].gb=='Y')
    {

    a[i].sum+=850;
    k+=850;
    }
    }
    for(i=0;i<n;i++)
    {
    for(j=i+1;j<n;j++)
    {
    if(a[j].sum>a[i].sum)
    swap(a[i],a[j]);
    }
    }
    j=a[0].sh;
    m=0;
    for(i=1;i<n;i++)
    {
    if(a[i].sum==a[0].sum)
    {
    if(a[i].sh<j)
    {
    j=a[i].sh;
    m=i;
    }
    }
    }
    cout<<a[m].name<<endl;
    cout<<a[m].sum<<endl;
    cout<<k<<endl;
    // system("pause");
    return 0;
    }
    #include <cstdlib>
    #include <iostream>
    #include <math.h>
    #include <time.h>
    #include <string.h>

    using namespace std;

    struct geren{
    char name[32];
    int qm;
    int bj;
    char gb;
    char xb;
    int lw;
    int sum;
    int sh;
    };

    geren a[101];

    int main(int argc,char *argv[])
    {
    int i,j,k,n,m;
    cin>>n;
    for(i=0;i<n;i++)
    {
    cin>>a[i].name>>a[i].qm>>a[i].bj>>a[i].gb>>a[i].xb>>a[i].lw;
    a[i].sum=0;
    a[i].sh=i;
    }
    k=0;
    for(i=0;i<n;i++)
    {
    if(a[i].qm>80 && a[i].lw>0)
    {
    a[i].sum+=8000;
    k+=8000;
    }
    if(a[i].qm>85 && a[i].bj>80)
    {
    a[i].sum+=4000;
    k+=4000;
    }
    if(a[i].qm>90)
    {

    a[i].sum+=2000;
    k+=2000;
    }
    if(a[i].qm>85 && a[i].xb=='Y')
    {
    a[i].sum+=1000;
    k+=1000;
    }
    if(a[i].bj>80 && a[i].gb=='Y')
    {

    a[i].sum+=850;
    k+=850;
    }
    }
    for(i=0;i<n;i++)
    {
    for(j=i+1;j<n;j++)
    {
    if(a[j].sum>a[i].sum)
    swap(a[i],a[j]);
    }
    }
    j=a[0].sh;
    m=0;
    for(i=1;i<n;i++)
    {
    if(a[i].sum==a[0].sum)
    {
    if(a[i].sh<j)
    {
    j=a[i].sh;
    m=i;
    }
    }
    }
    cout<<a[m].name<<endl;
    cout<<a[m].sum<<endl;
    cout<<k<<endl;
    // system("pause");
    return 0;
    }
    #include <cstdlib>
    #include <iostream>
    #include <math.h>
    #include <time.h>
    #include <string.h>

    using namespace std;

    struct geren{
    char name[32];
    int qm;
    int bj;
    char gb;
    char xb;
    int lw;
    int sum;
    int sh;
    };

    geren a[101];

    int main(int argc,char *argv[])
    {
    int i,j,k,n,m;
    cin>>n;
    for(i=0;i<n;i++)
    {
    cin>>a[i].name>>a[i].qm>>a[i].bj>>a[i].gb>>a[i].xb>>a[i].lw;
    a[i].sum=0;
    a[i].sh=i;
    }
    k=0;
    for(i=0;i<n;i++)
    {
    if(a[i].qm>80 && a[i].lw>0)
    {
    a[i].sum+=8000;
    k+=8000;
    }
    if(a[i].qm>85 && a[i].bj>80)
    {
    a[i].sum+=4000;
    k+=4000;
    }
    if(a[i].qm>90)
    {

    a[i].sum+=2000;
    k+=2000;
    }
    if(a[i].qm>85 && a[i].xb=='Y')
    {
    a[i].sum+=1000;
    k+=1000;
    }
    if(a[i].bj>80 && a[i].gb=='Y')
    {

    a[i].sum+=850;
    k+=850;
    }
    }
    for(i=0;i<n;i++)
    {
    for(j=i+1;j<n;j++)
    {
    if(a[j].sum>a[i].sum)
    swap(a[i],a[j]);
    }
    }
    j=a[0].sh;
    m=0;
    for(i=1;i<n;i++)
    {
    if(a[i].sum==a[0].sum)
    {
    if(a[i].sh<j)
    {
    j=a[i].sh;
    m=i;
    }
    }
    }
    cout<<a[m].name<<endl;
    cout<<a[m].sum<<endl;
    cout<<k<<endl;
    // system("pause");
    return 0;
    }

  • 0
    @ 2014-03-02 21:28:38

    #include <cstdlib>
    #include <iostream>
    #include <math.h>
    #include <time.h>
    #include <string.h>

    using namespace std;

    struct geren{
    char name[32];
    int qm;
    int bj;
    char gb;
    char xb;
    int lw;
    int sum;
    int sh;
    };

    geren a[101];

    int main(int argc,char *argv[])
    {
    int i,j,k,n,m;
    cin>>n;
    for(i=0;i<n;i++)
    {
    cin>>a[i].name>>a[i].qm>>a[i].bj>>a[i].gb>>a[i].xb>>a[i].lw;
    a[i].sum=0;
    a[i].sh=i;
    }
    k=0;
    for(i=0;i<n;i++)
    {
    if(a[i].qm>80 && a[i].lw>0)
    {
    a[i].sum+=8000;
    k+=8000;
    }
    if(a[i].qm>85 && a[i].bj>80)
    {
    a[i].sum+=4000;
    k+=4000;
    }
    if(a[i].qm>90)
    {

    a[i].sum+=2000;
    k+=2000;
    }
    if(a[i].qm>85 && a[i].xb=='Y')
    {
    a[i].sum+=1000;
    k+=1000;
    }
    if(a[i].bj>80 && a[i].gb=='Y')
    {

    a[i].sum+=850;
    k+=850;
    }
    }
    for(i=0;i<n;i++)
    {
    for(j=i+1;j<n;j++)
    {
    if(a[j].sum>a[i].sum)
    swap(a[i],a[j]);
    }
    }
    j=a[0].sh;
    m=0;
    for(i=1;i<n;i++)
    {
    if(a[i].sum==a[0].sum)
    {
    if(a[i].sh<j)
    {
    j=a[i].sh;
    m=i;
    }
    }
    }
    cout<<a[m].name<<endl;
    cout<<a[m].sum<<endl;
    cout<<k<<endl;
    system("pause");
    return 0;
    }

  • 0
    @ 2014-02-04 23:57:51

    #include<stdio.h>
    struct student

    {

    char name[30];
    int qm;
    int bj;
    char gb;
    char xb;
    int lw;
    int ss;
    };

    int main()
    {
    student s[110];
    int n,m,i;
    int sum=0;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
    scanf("%s %d %d %c %c %d",&s[i].name,&s[i].qm,&s[i].bj,&s[i].gb,&s[i].xb,&s[i].lw);
    s[i].ss=0;
    if(s[i].qm>80&&s[i].lw>0) s[i].ss+=8000;
    if(s[i].qm>85&&s[i].bj>80) s[i].ss+=4000;
    if(s[i].qm>90) s[i].ss+=2000;
    if(s[i].xb=='Y'&&s[i].qm>85) s[i].ss+=1000;
    if(s[i].bj>80&&s[i].gb=='Y') s[i].ss+=850;
    sum+=s[i].ss;
    if(i==0) m=0;
    else
    {
    if(s[i].ss>s[m].ss) m=i;
    }
    }
    printf("%s\n%d\n%d\n",s[m].name,s[m].ss,sum);
    return 0;
    }

  • 0
    @ 2014-01-20 11:52:08

    #include<stdio.h>
    int main()
    {
    char name[100][20],gb[100],xb[100];
    int i,n,pj[100],py[100],lw[100],max=0,h=0,max2=0,temp=0;
    for(i=0;i<n;i++)
    {
    scanf("%s %d %d %c %c %d",name[i],&pj[i],&py[i],&gb[i],&xb[i],&lw[i]);
    if(pj[i]>80 && lw[i]>=1)temp+=8000;
    if(pj[i]>85 && py[i]>80)temp+=4000;
    if(pj[i]>90)temp+=2000;
    if(pj[i]>85 && xb[i]=="Y")temp+=1000;
    if(py[i]>80 && gb[i]=="Y")temp+=850;
    if(temp>max){max=temp;max2=i;};
    h+=temp;
    temp=0;
    }
    printf("%s\n%d\n%d",name[max2],max,h);
    return 0;
    }
    一直ce啥情况

  • 0
    @ 2014-01-20 11:50:44

    ###block code
    #include<stdio.h>
    int main()
    {
    char name[100][20],gb[100],xb[100];
    int i,n,pj[100],py[100],lw[100],max=0,h=0,max2=0,temp=0;
    for(i=0;i<n;i++)
    {
    scanf("%s %d %d %c %c %d",name[i],&pj[i],&py[i],&gb[i],&xb[i],&lw[i]);
    if(pj[i]>80 && lw[i]>=1)temp+=8000;
    if(pj[i]>85 && py[i]>80)temp+=4000;
    if(pj[i]>90)temp+=2000;
    if(pj[i]>85 && xb[i]=="Y")temp+=1000;
    if(py[i]>80 && gb[i]=="Y")temp+=850;
    if(temp>max){max=temp;max2=i;};
    h+=temp;
    temp=0;
    }
    printf("%s\n%d\n%d",name[max2],max,h);
    return 0;
    }
    这哪里有问题一直ce

  • 0
    @ 2014-01-04 18:43:43
  • 0
    @ 2014-01-01 11:57:08

    Vijos 题解:http://hi.baidu.com/umule/item/2c997f8ed9600fdae596e017
    有疑问请留言 共同进步

  • 0
    @ 2013-12-12 13:34:16

    ###代码
    var qm,bg,lw,mn,bj:array[1..100] of integer;
    i,j,n,y,z:integer;
    zongfen:longint;
    name,b:string;
    xb,gb:array[1..100] of char;
    begin
    readln(n);
    for i:=1 to n do
    read(name[i]);
    read(qm[i]);
    read(bj[i]);
    read(gb[i]);
    read(xb[i]);
    read(lw[i]);
    for i:=1 to n do
    begin
    if (qm[i]>80) and (lw[i]>=1) then mn[i]:=mn[i]+8000;
    if (qm[i]>85) and (bj[i]>80) then mn[i]:=mn[i]+4000;
    if (qm[i]>90) then mn[i]:=mn[i]+2000;
    if (xb[i]='Y') and (qm[i]>85) then mn[i]:=mn[i]+1000;
    if (bj[i]>80) then mn[i]:=mn[i]+850;
    end;
    j:=0;
    for i:=1 to n do zongfen:=zongfen+mn[i];
    for i:=1 to n do
    begin
    if mn[i]>j then
    begin
    j:=mn[i];
    b:=name[i];
    y:=mn[i];
    z:=zongfen;
    end;
    end;
    end.
    为什么运行时错误。。。求助

  • 0
    @ 2013-12-10 22:01:12

    program test;
    var
    a,b,c,d,n:string;
    i,j,k,x,y,z,r,v,s:integer;
    t:longint;
    begin
    readln(k);
    for i:=1 to k do
    begin
    readln(a);
    j:=pos(' ',a);
    b:=copy(a,1,j-1);
    delete(a,1,j);
    j:=pos(' ',a);
    val(copy(a,1,j-1),x,r);
    delete(a,1,j);
    j:=pos(' ',a);
    val(copy(a,1,j-1),y,r);
    delete(a,1,j);
    j:=pos(' ',a);
    c:=copy(a,1,j-1);
    delete(a,1,j);
    j:=pos(' ',a);
    d:=copy(a,1,j-1);
    delete(a,1,j-1);
    val(copy(a,1,length(a)),z,r);
    if (x>80) and (z>=1) then v:=v+8000;
    if (x>85) and (y>80) then v:=v+4000;
    if x>90 then v:=v+2000;
    if (x>85) and (d='Y') then v:=v+1000;
    if (x>80) and (c='Y') then v:=v+850;
    if s<v then
    begin
    s:=v;
    n:=b;
    end;
    t:=t+v;
    v:=0;
    end;
    writeln(n);
    writeln(s);
    writeln(t);
    end.

  • 0
    @ 2013-12-03 18:06:34

    以此庆祝我的第一个c++程序
    #include<iostream>
    #include<cstdio>
    using namespace std;
    int main()
    { char kun,gan;
    char name[101][100];
    int max,mark,classmark;
    int n,wen,jiang[101];
    cin>>n;
    max=0;
    int i;
    for (i=1;i<=n;i++)
    {
    scanf("%s %d %d %c %c %d",name[i],&mark,&classmark,&gan,&kun,&wen);
    jiang[i]=0;
    if ((mark>80)&&(wen>=1))
    {jiang[i]+=8000;}
    if ((mark>85)&&(classmark>80))
    {jiang[i]+=4000;}
    if (mark>90)
    {
    jiang[i]+=2000;
    }
    if ((mark>85)&&((int) kun == (int)'Y'))
    {
    jiang[i]+=1000;
    }
    if ((classmark>80)&&((int) gan== (int)'Y'))
    {
    jiang[i]+=850;
    }
    if (jiang[i]>max) {max=jiang[i];}
    }
    int sum=0;
    for (i=1;i<=n;i++)
    {
    sum+=jiang[i];
    }
    for (i=1;i<=n;i++)
    {
    if (max==jiang[i]){printf("%s\n",name[i]);printf("%d\n",jiang[i]);break;}
    }
    printf("%d\n",sum);
    return 0;
    }

  • 0
    @ 2013-12-01 21:41:01

    #include <cstdio>
    #include <cstring>
    #include <algorithm>
    #define REP( i, n ) for ( int i = 1; i <= n; i ++ )
    #define FOR( i, a, b ) for ( int i = a; i <= b; i ++ )
    #define DWN( i, a, b ) for ( int i = b; i >= a; i -- )
    #define RST( a, x ) memset ( a, x, sizeof ( a ) );
    #define QN q[ i ].name
    #define QS1 q[ i ].scr1
    #define QS2 q[ i ].scr2
    #define QT q[ i ].stu
    #define QW q[ i ].west
    #define QP q[ i ].pap
    #define QZ q[ i ].prz
    #define QO q[ i ].pos
    #define TRUE == 'Y'
    #define NSIZE 102
    #define ONLINE_JUDGE NULL

    using namespace std;
    struct arr
    {
    char name[ 30 ], stu[ 3 ], west[ 3 ];
    int scr1, scr2, pap, prz, pos;
    };
    int n, ans = 0;
    arr q[ NSIZE ];
    bool cmp ( arr a, arr b )
    {
    if ( a.prz != b.prz ) return a.prz > b.prz;
    return a.pos < b.pos;
    }
    int main ()
    {

    #ifndef ONLINE_JUDGE
    freopen ( "P1001.in", "r", stdin );
    freopen ( "P1001.out", "w", stdout );
    #endif

    scanf ( "%d", &n );
    REP ( i, n )
    {
    scanf ( "%s%d%d%s%s%d", QN, &QS1, &QS2, QT, QW, &QP );
    QZ = 0; QO = i;
    if ( QS1 > 80 && QP ) QZ += 8000;
    if ( QS1 > 85 && QS2 > 80 ) QZ += 4000;
    if ( QS1 > 90 ) QZ += 2000;
    if ( QS1 > 85 && QW[ 0 ] TRUE ) QZ += 1000;
    if ( QS2 > 80 && QT[ 0 ] TRUE ) QZ += 850;
    ans += QZ;
    }
    sort ( q + 1, q + n + 1, cmp );
    printf ( "%s\n%d\n%d\n", q[ 1 ].name, q[ 1 ].prz, ans );
    return 0;
    }
    想不通以前怎么写的……

  • 0
    @ 2013-11-08 20:57:25

    var i,n,max,m,sum,a1,a2,b:longint;
    ch,kong,p1,p2:char;
    name,ans:string;
    begin
    readln(n);
    max:=0;
    for i:=1 to n do begin
    m:=0; name:='';
    while true do begin
    read(ch);
    if ch<>' ' then name:=name+ch else break;
    end;
    readln(a1,a2,kong,p1,kong,p2,b);
    if (a1>80)and(b>0) then m:=m+8000;
    if (a1>85)and(a2>80) then m:=m+4000;
    if a1>90 then m:=m+2000;
    if (a1>85)and(p2='Y') then m:=m+1000;
    if (a2>80)and(p1='Y') then m:=m+850;
    if m>max then begin
    max:=m;
    ans:=name;
    end;
    sum:=sum+m;
    end;
    writeln(ans);
    writeln(max);
    writeln(sum);
    end.

  • 0
    @ 2013-11-03 09:30:25

    program p1001;
    var name:array[0..100,0..20]of char;
    n:integer;
    qm,bp,lw:array[0..100]of integer;
    gb,xb:array[0..100]of boolean;
    jxj:array[0..100]of longint;
    num,max:longint;
    ////////////////////////////////////////////////////////////////////////////////
    procedure init;
    var ch:char;
    i,j,k:integer;
    begin
    for i:=0 to 100 do
    for j:=0 to 20 do
    name[i,j]:=' ';
    readln(n);
    for i:=1 to n do
    begin
    read(ch);
    k:=0;
    while ch<>' ' do
    begin
    inc(k);
    name[i,k]:=ch;
    read(ch);
    end;
    read(qm[i],bp[i]);
    read(ch);read(ch);
    if ch='Y' then gb[i]:=true
    else gb[i]:=false;
    read(ch);read(ch);
    if ch='Y' then xb[i]:=true
    else xb[i]:=false;
    readln(lw[i]);
    end;
    end;
    ////////////////////////////////////////////////////////////////////////////////
    procedure main;
    var nn,i:integer;
    begin
    num:=0;max:=0;
    fillchar(jxj,sizeof(jxj),0);
    for i:=1 to n do
    begin
    if (qm[i]>80)and(lw[i]>=1) then jxj[i]:=jxj[i]+8000;
    if (qm[i]>85)and(bp[i]>80) then jxj[i]:=jxj[i]+4000;
    if qm[i]>90 then jxj[i]:=jxj[i]+2000;
    if (qm[i]>85)and(xb[i]) then jxj[i]:=jxj[i]+1000;
    if (bp[i]>80)and(gb[i]) then jxj[i]:=jxj[i]+850;
    if (jxj[i]>max)or(max=0) then
    begin
    max:=jxj[i];
    nn:=i;
    end;
    num:=num+jxj[i];
    end;
    for i:=1 to 20 do
    begin
    if name[nn,i]<>' ' then write(name[nn,i]);
    end;
    writeln;
    writeln(max);
    writeln(num);
    end;
    ////////////////////////////////////////////////////////////////////////////////
    begin
    init;
    main;
    end.

  • 0
    @ 2013-10-31 10:22:39

    #include <stdio.h>

    #define N 100

    int main(){
    char name[N][20],of[N],we[N];
    int i,n,fe[N],ca[N],ar[N],maxi,maxb,bo[N];
    long total;

    scanf("%d", &n);
    for (i=0; i<n; i++){
    scanf("%s %d %d %c %c %d", name[i], &fe[i], &ca[i],\
    &of[i], &we[i], &ar[i]);
    }
    total=0;
    maxi=0;
    maxb=0;
    for (i=0; i<n; i++){
    bo[i]=0;
    if ((fe[i]>80) && (ar[i]>=1)) bo[i]+=8000;
    if ((fe[i]>85) && (ca[i]>80)) bo[i]+=4000;
    if (fe[i]>90) bo[i]+=2000;
    if ((fe[i]>85) && (we[i]=='Y')) bo[i]+=1000;
    if ((ca[i]>80) && (of[i]=='Y')) bo[i]+=850;
    total+=bo[i];
    if (maxb<bo[i]) {
    maxb=bo[i];
    maxi=i;
    }
    }
    printf("%s\n%d\n%ld", name[maxi], bo[maxi], total);
    return 0;
    }

    为什么总是40分?求解。

  • 0
    @ 2013-10-31 10:22:29

    #include <stdio.h>

    #define N 100

    int main(){
    char name[N][20],of[N],we[N];
    int i,n,fe[N],ca[N],ar[N],maxi,maxb,bo[N];
    long total;

    scanf("%d", &n);
    for (i=0; i<n; i++){
    scanf("%s %d %d %c %c %d", name[i], &fe[i], &ca[i],\
    &of[i], &we[i], &ar[i]);
    }
    total=0;
    maxi=0;
    maxb=0;
    for (i=0; i<n; i++){
    bo[i]=0;
    if ((fe[i]>80) && (ar[i]>=1)) bo[i]+=8000;
    if ((fe[i]>85) && (ca[i]>80)) bo[i]+=4000;
    if (fe[i]>90) bo[i]+=2000;
    if ((fe[i]>85) && (we[i]=='Y')) bo[i]+=1000;
    if ((ca[i]>80) && (of[i]=='Y')) bo[i]+=850;
    total+=bo[i];
    if (maxb<bo[i]) {
    maxb=bo[i];
    maxi=i;
    }
    }
    printf("%s\n%d\n%ld", name[maxi], bo[maxi], total);
    return 0;
    }

    为什么总是40分?求解。

  • 0
    @ 2013-10-24 22:35:17

    为什么总是runtime error???

    #include<iostream>
    using namespace std;
    #include<stdio.h>
    int main(){
    char letter,name[22][101],namemax[21],text[3][101];
    int score[4][101],lunwen[101];
    int n,i,j,sum=0,max=0;
    cin>>n;
    for(i=1,j=1;i<=n;i++)
    {j=1;
    scanf("%c",letter);
    for(;letter!=' ';)
    {name[i][j++]=letter;
    scanf("%c",letter);}

    for(j=1;j<=2;j++)
    scanf("%d",&score[i][j++]);
    scanf("%d",&score[i][j]);
    scanf("%d",&lunwen[i]);
    if(score[i][1]>80&&lunwen[i]>0)score[i][3]+=8000;
    if(score[i][1]>85&&score[i][2]>80)score[i][3]+=4000;
    if(score[i][1]>90)score[i][3]+=2000;
    if(score[i][1]>85&&text[i][2]=='Y')score[i][3]+=1000;
    if(score[i][2]>80&&text[i][1]=='Y')score[i][3]+=850;
    sum+=score[i][3];
    if(score[i][3]>max)
    {max=score[i][3];
    for(j=1;j<=20;j++)
    namemax[j]=name[i][j];}
    }
    for(i=1;namemax[i];i++)
    printf("%c",namemax[i]);
    cout<<' '<<max<<sum;
    return 0;
    }

  • 0
    @ 2013-10-06 08:13:07

    第一次写RECORD类型。。。表示压力山大。
    主要是 CARDE 和 WEST 的输入比较坑爹 。
    以下是AC程序
    var i,j,k,l,n,m,ans1,max:longint;
    student:array[0..1000] of record
    name:string;
    score:longint;
    classes:longint;
    carde:string[2];
    west:string[2];
    article:longint;
    money:longint;
    end;
    c:char;
    ans:string;

    begin
    readln(n);
    for i:=1 to n do
    with student[i] do begin
    name:='';
    c:='a';
    while c<>' ' do begin
    read(c);
    if c<>' ' then name:=name+c;
    end;
    read(score);
    read(classes);
    read(carde);
    read(west);
    readln(article);
    if (score>80) and (article>=1) then money:=money+8000;
    if (score>85) and (classes>80) then money:=money+4000;
    if (score>90) then money:=money+2000;
    if (score>85) and (west=' Y') then money:=money+1000;
    if (classes>80) and (carde=' Y') then money:=money+850;
    if money>max then begin
    max:=money;
    ans:=name;
    end;
    ans1:=ans1+money;
    end;
    writeln(ans);
    writeln(max);
    writeln(ans1);
    end.

  • 0
    @ 2013-09-02 22:59:16

    来个纯 C 的...

    #include <stdio.h>
    #include <strings.h>

    struct stu_info
    {
    char name[20];
    int avg;
    int brownie;
    char is_representative;
    char is_from_west;
    int paper;
    };

    int calc_scholarship(struct stu_info si);

    int main()
    {
    struct stu_info si;
    int num, i = 0, scholarship, max_sch = 0, total = 0;
    char max_name[20];

    scanf(" %d", &num);

    for (; i < num; i++)
    {
    scanf(" %s %d %d %c %c %d", si.name, &si.avg, &si.brownie, &si.is_representative, &si.is_from_west, &si.paper);

    scholarship = calc_scholarship(si);
    total += scholarship;

    if (scholarship > max_sch)
    {
    max_sch = scholarship;
    strcpy(max_name, si.name);
    }
    }

    printf("%s\n%d\n%d", max_name, max_sch, total);

    return 0;
    }

    int calc_scholarship(struct stu_info si)
    {
    int scholarship = 0;

    if (si.avg > 80 && si.paper >= 1)
    scholarship += 8000;

    if (si.avg > 85 && si.brownie > 80)
    scholarship += 4000;

    if (si.avg > 90)
    scholarship += 2000;

    if (si.avg > 85 && si.is_from_west == 'Y')
    scholarship += 1000;

    if (si.brownie > 80 && si.is_representative == 'Y')
    scholarship += 850;

    return scholarship;
    }

  • 0
    @ 2013-08-31 16:57:15

    水题不多说。直接读入之后累加奖学金,然后找最大值即可。如果是PASCAL,那么读入可能会比较麻烦,C++可以直接用scanf读入。

    #include <cstdio>
    #include <cstring>

    struct student
    {
    char name[30],lead[3],west[3];
    int s1,s2,art;
    void cls()
    {
    memset(name,0,sizeof(name));
    memset(lead,0,sizeof(lead));
    memset(west,0,sizeof(west));
    s1=s2=art=0;
    }
    };

    student T;
    int max,tot,N,i,tmp;
    char ans[30];

    int main()
    {
    scanf("%d",&N);
    for (i=0;i<N;i++)
    {
    T.cls();
    tmp=0;
    scanf("%s%d%d%s%s%d",T.name,&T.s1,&T.s2,T.lead,T.west,&T.art);
    if (T.s1>80&&T.art>=1) tmp+=8000;
    if (T.s1>85&&T.s2>80) tmp+=4000;
    if (T.s1>90) tmp+=2000;
    if (T.s1>85&&T.west[0]=='Y') tmp+=1000;
    if (T.s2>80&&T.lead[0]=='Y') tmp+=850;
    if (tmp>max)
    {
    max=tmp;
    memset(ans,0,sizeof(ans));
    strcpy(ans,T.name);
    }
    tot+=tmp;
    }
    printf("%s\n%d\n%d\n",ans,max,tot);
    return 0;
    }

  • 0
    @ 2013-08-31 14:03:13

信息

ID
1001
难度
5
分类
模拟 点击显示
标签
递交数
39260
已通过
12791
通过率
33%
被复制
130
上传者