`

Life, the Universe, and Everything

    博客分类:
  • SPOJ
阅读更多
此题很水,只是第一次看到这个题目的时候有点弄不懂题意,试了一下,才发现只要遇到42就停止输入,而不是继续读入而不处理。

1. Life, the Universe, and Everything
Problem code: TEST

Your program is to use the brute-force approach in order to find the Answer to Life, the Universe, and Everything. More precisely... rewrite small numbers from input to output. Stop processing input after reading in the number 42. All numbers at input are integers of one or two digits.



Example

Input:
1
2
88
42
99

Output:
1
2
88

AC代码:
#include <iostream>
using namespace std;
int main()
{
    int a;
    while(cin>>a)
    {
        if(a==42)   break;
        cout<<a<<endl;
    }
   // while(cin>>a);此处必须去掉,否则为WA
    return 0;
}

分享到:
评论

相关推荐

    the-answer-to-the-ultimate-question-of-life-the-universe-and-everything:42

    npm install the-answer-to-the-ultimate-question-of-life-the-universe-and-everything 用法 需要模块 var theAnswerToTheUltimateQuestionOfLifeTheUniverseAndEverything = require ( 'the-answer-to-the-...

    goolew网址大全

    还有,当用户搜索特定问题,如"what is the answer to life the universe and everything?"(生命、宇宙以及所有一切事物的答案是什么?),Google会回应42,这是来自《银河系漫游指南》的幽默引用,展示了Google的...

    55 Ways to Have Fun with Google

    这个梗被谷歌工程师所采纳,并在谷歌计算器中加入了计算“life the universe and everything”的功能,结果正是42。这是一个对科幻爱好者的小彩蛋,也是对谷歌幽默感的一次展示。 ### 十二、我又谷歌了:误打误撞的...

    The hitchhiker's guide to the galax

    3. **《生命、宇宙及一切》(Life, the Universe and Everything)** 4. **《再见,谢谢鱼》(So Long, and Thanks for All the Fish)** 5. **《青年扎普福德稳操胜券》(Young Zaphod Plays It Safe)** 此外,还有一部...

    Being Wrong Kathryn Schulz

    To err is human Yet most of us go through life assuming and sometimes insisting that we are right about nearly everything from the origins of the universe to how to load the dishwasher If being wrong ...

    Machine Learning for Decision Makers-Apress(2017).pdf

    Machine learning made it possible to generate a complete universe of business applications, products, and capabilities that serve customers and enhance life experiences of the individuals across ...

    matlab代码字节数-matlab-msgpack:msgpack.org[Matlab]

    life, the universe, and everything ' , struct( ' the_answer ' , 42 )}; bytes = dumpmsgpack(data) data = parsemsgpack(bytes) % returns: {'life, the universe, and everything', containers.Map('the_answer...

    opentok-rpc:OpenTok的RPC扩展

    OpenTok RPC OpenTok RPC将远程(基于承诺)过程调用... log ( 'The Answer to the Ultimate Question of Life, The Universe, and Everything:' , result ) ; } ) ; 安装 添加OpenTok库后,只需包含库即可。 OpenTok

    测试运行器Preceptor.zip

    it('should know the answer to life, the universe, and everything', function () {  assert.equal(lib.answerToLifeTheUniverseAndEverything(), 42); }); describe('The End', function ...

    八下动词练习.pdf

    1. **现在完成时**:如"Astronauts have found many galaxies in the universe so far."、"We have formed close friendships so far."、"She has visited several countries so far." 这些句子中的动词都用现在完成...

    八下动词.pdf

    如例子所示,Astronauts have discovered many galaxies in the universe so far. 这表明发现银河系的动作在过去发生,至今仍在影响着我们。 2. **并列连词And的时态一致**:当And连接两个句子时,前后动词时态通常...

    正能量早上好的句子.doc

    2. **目标设定**:“How can I best serve the universe today?” 这不仅是对他人服务的思考,也是对自我价值实现的追求,IT从业者可以将其转化为如何通过技术服务于社会,推动科技进步。 3. **积极预期**:“I am ...

    TheAnswerToLifeTheUniverseAndEverything:一个 Node.js npm 模块,它返回生命宇宙和一切的答案

    const answer = require('the-answer-to-life-the-universe-and-everything'); console.log(answer()); // 输出:42 ``` 这个简单的调用背后,其实隐藏着 Node.js 对异步编程的理解。由于 Node.js 是单线程的,这...

    cmke与ctest、gtest绑定使用

    EXPECT_EQ(42, answer_to_life_the_universe_and_everything()); } ``` 3. **添加测试到CTest**:在CMakeLists.txt中,使用`add_test`命令将gtest测试用例添加到CTest。 ```cmake add_test(NAME MyTest COMMAND $...

    delphi多线程详解

    // The answer to life, the universe, and everything! end; ``` 在这个示例中,我们定义了一个名为`TBackgroundThread`的新线程类,该类继承自`TThread`。在`Execute`方法中模拟了一个长时间运行的任务。通过在...

    node.js中使用node-schedule实现定时任务实例

    console.log('The answer to life, the universe, and everything!'); }); ``` 3. **每周特定天的特定时间** 要在一周中的某些天(如周四至周日)的特定时间(如17点)执行任务,可以设置`dayOfWeek`和`hour`...

Global site tag (gtag.js) - Google Analytics