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 }

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

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

  • 相关阅读:
    八月最后的一天
    Go语言系列一
    一个工具libre draw
    Linux启动eclipse报错找不到java环境解决方法
    P2P通讯初步实现
    C#中,当鼠标移动到控件上,动态显示提示内容 ToolTip
    在windows64位的系统上面操作操作excel程序出现异常
    office2007下载地址
    蜗牛算法
    利用vs自带工具分析程序性能
  • 原文地址:https://www.cnblogs.com/qyddbear/p/2410094.html
Copyright © 2011-2022 走看看