| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2037 人关注过本帖
标题:各位大佬,求帮看看问题出在哪里了
只看楼主 加入收藏
Mstdio
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2016-12-5
结帖率:0
收藏
已结贴  问题点数:5 回复次数:1 
各位大佬,求帮看看问题出在哪里了
这是题目:
题目描述
Fubery found he start to fall in love with lottle school-sister Funv .

As a university fresh man , can you ren ?

Now , try to destroy it !

There are 6 numbers .

You can change the order of the 6 numbers.

Then Funv will take the firse one and the last one , sum the up as her score.

Finally , Fubery can take any of 3 numbers from the left 4 numbers ,and sum them up as his score .

If Fuber's score is smaller than Funv,s , he  will lose . If bigger , he will win. if there are equal , HeHe !

输入
There is a number T shows there are T test cases below. ( T <= 50)

For each test case , there are 6 numbers X ( 1 <= X <= 100 ).


输出
If Fubery loses , outout "What a sad story!"

If Fubery win , output "It will be a sad story!"

If they are equal , output "HeHe!"

样例输入
3
1 2 3 3 2 2
5 6 4 3 5 5
1 2 2 2 3 4
样例输出
HeHe!
It will be a sad story!
What a sad story!

这是我写的代码:
#include <iostream>
using namespace std;
int main()
{
int T,i,j,t,w,m,a[6];
while(cin>>T)
{
for(i=0;i<6;i++)
cin>>a[i];
for(j=1;j<6;j++)
for(i=1;i<=6-j;i++)
{
if(a[i]>a[i+1])
{t=a[i];a[i]=a[i+1];a[i+1]=t}
}
w=a[6]+[5];
m=a[4]+a[3]+a[2];
if(w>m)
cout<<"What a sad story!";
else if(w==m)
cout<<"HeHe!";
else cout<<"It will be a sad story!";
}
return 0;
}
搜索更多相关主题的帖子: university numbers change bigger start 
2016-12-29 08:55
rjsp
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:528
帖 子:9007
专家分:53942
注 册:2011-1-18
收藏
得分:5 
程序代码:
#include <iostream>
#include <algorithm>
using namespace std;

int main( void )
{
    unsigned T;
    cin >> T;
    while( T-- )
    {
        unsigned X[6];
        for( size_t i=0; i!=6; ++i )
            cin >> X[i];

        std::sort( X+0, X+6 );

        unsigned Funv = X[4]+X[5];
        unsigned Fubery = X[1]+X[2]+X[3];
        if( Fubery < Funv )
            cout << "What a sad story!\n";
        else if( Fubery > Funv )
            cout << "It will be a sad story!\n";
        else
            cout << "HeHe!\n";
    }

    return 0;
}
2016-12-29 09:56
快速回复:各位大佬,求帮看看问题出在哪里了
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015394 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved