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 }

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

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

  • 相关阅读:
    beautifulsoup部分知识点
    navicat 结合快捷键
    byte[i] & 0xFF原因(byte为什么要与上0xff?)
    Java parseInt()和parseFloat()的用法
    parse 方法
    getTime()和parse()的区别
    使用SQL Profiler trace(2005)的经验分享(新建跟踪、分析跟踪文件)
    DWZ使用笔记
    js中 json详解
    src与href属性的区别
  • 原文地址:https://www.cnblogs.com/qyddbear/p/2410094.html
Copyright © 2011-2022 走看看