`

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-...

    The hitchhiker's guide to the galax

    银河系漫游指南英文版,The Hitch Hiker’s Guide to the Galaxy The Restaurant at the End of the Universe Life, the Universe and Everything So Long, and Thanks for All the Fish

    对句子进行调整的简单C++程序

    它读入一个最长100个字符的句子,对这个句子进行调整,...the Answer to life ,the Universe,and everything Is 42.输出的是 The answer to life,the universe,and everything is 42. 这只是一个简单版本的。水平有限。

    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 ...

    linux program

    considers planning and accomplishing a first-ascent expedition to the vast arctic glaciers of east Greenland to be the really unique achievement in his life. Being interested in everything that is ...

    Linux® Kernel Architecture

    Being interested in everything that is fundamental, he is also the author of the first compiler for Plankalk ¨ ul, the world’s earliest high-level language devised in 1942–1946 by Konrad Zuse, the ...

    linux architecture

    Being interested in everything that is fundamental, he is also the author of the first compiler for Plankalk ¨ ul, the world’s earliest high-level language devised in 1942–1946 by Konrad Zuse, the ...

    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

    2008年6月大学英语六级A卷真题

    They may also change the way we look at ourselves and our place in the universe.” Colonies in space Richard Gott, professor of astrophysics at Princeton, hopes man will set up a self-sufficient ...

    测试运行器Preceptor.zip

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

Global site tag (gtag.js) - Google Analytics