zoukankan      html  css  js  c++  java
  • ACM练习:【ID1001】Easy or not?

    Problem 1001
    Easy or not
    Time Limit: 1000ms
    Memory Limit: 65536kb
    Description

    We are wondering how easy a problem can be. According to recent research, the most easy problem may be the one which requires to output exactly the input, other than the classical A+B Problem.
    As our best programmer, you are asked to write a program to prove the conclusion.

    Input

    Lots of characters.

    Output

    Characters exactly the same as input.

    Sample Input
    The quick brown fox jumps over the lazy dog.
    question = to ? be : !be;
    Sample Output
    The quick brown fox jumps over the lazy dog.
    question = to ? be : !be;
    Hint

    Huge input


    (1)

     1 #include<iostream>
    2 using namespace std;
    3
    4 int main()
    5 {
    6 int c;
    7
    8 while((c=getchar())!=EOF)
    9 {
    10 putchar(c);
    11 }
    12
    13 return 0;
    14 }

    小结:解法(1)虽然实现了用例测试,根据编译信息,所使用的getchar()和putchar()函数在cstdio库中,并非iostream里,因此虽然VS可行,但online编译未通过。


    (2)

    更改头文件#include<iostream>为#include<cstdio>

    注意如果把while((c=getchar())!=EOF)改为while((c=getchar())!='\n'),则是错误的答案,因为大量的文件输入,可能会中途换行。

     1 #include<cstdio>
    2 using namespace std;
    3
    4 int main()
    5 {
    6 int c;
    7
    8 while((c=getchar())!='EOF')
    9 {
    10 putchar(c);
    11 }
    12
    13 return 0;
    14 }

    小结:这显然不是个好算法,耗时。

    总结:有好的想法会继续更新。欢迎指正。

  • 相关阅读:
    单元测试利器 JUnit 4 Mr
    firefox插件介绍 Mr
    js函数使用技巧集合 Mr
    单点登录
    2.SilverLight动态加载控件
    3.如何获取动态生成的SL控件的NAME值(一)
    ASP.Net中控件的EnableViewState属性 【转】
    三种在ASP.NET中重写URL的方法
    SQLHelper.cs
    c# IS与AS的使用方法
  • 原文地址:https://www.cnblogs.com/qyddbear/p/2410094.html
Copyright © 2011-2022 走看看