一个适合小白的,通俗易懂的程序

P1046 [NOIP2005 普及组] 陶陶摘苹果

杰杰 @ 2017-10-05 22:55:52

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,d,e,f,g,h,i,j,l;
    cin>>a>>b>>c>>d>>e>>f>>g>>h>>i>>j;
    cin>>l;
    int  k;
    k=l+30;
    int ans=0;
    while(a<=k)
    {
        ans++;
        a=k+1;
    }
    while(b<=k)
    {
        ans++;
        b=k+1;
    }
    while(c<=k)
    {
        ans++;
        c=k+1;
    }
    while(d<=k)
    {
        ans++;
        d=k+1;
    }
    while(e<=k)
    {
        ans++;
        e=k+1;
    }
    while(f<=k)
    {
        ans++;
        f=k+1;
    }
    while(g<=k)
    {
        ans++;
        g=k+1;
    }
    while(h<=k)
    {
        ans++;
        h=k+1;
    }
    while(i<=k)
    {
        ans++;
        i=k+1;
    }
    while(j<=k)
    {
        ans++;
        j=k+1;
    }
    cout<<ans;
}

by cszmc2004 @ 2017-10-06 07:27:15

你的代码太长了,看着都晕


by YaliKiWi @ 2017-10-06 08:12:00

+1


by Lolierl @ 2017-10-06 08:45:47

这已经很通俗易懂了 怎么不用二分答案呢


by 市场花园行动 @ 2017-10-11 21:36:56

+1


by 白菜煎饼 @ 2017-11-04 09:36:08

用数组也能缩短啊


|