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 }

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

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

  • 相关阅读:
    编译impala2.0.0
    CentOS 7 安装Boost 1.61
    CentOS 6.4 编译安装LLVM3.3,Clang和Libc++
    批量修改dos文件到unix
    git win7 dos下设置代理
    vim源码编译启用python
    一张图看懂天津市教育云服务平台
    关于git中Pageant开机启动且自动关联秘钥
    Windows 10安装pip方法
    大数据中心的业务研发路线
  • 原文地址:https://www.cnblogs.com/qyddbear/p/2410094.html
Copyright © 2011-2022 走看看