[Login|Register]
New post

Show post

Search forum

Read topic
这代码能得到正确结果啊,怎么老是Time Limit Exceeded... 2012-01-19 20:49:57 bboybhappy
#include <iostream>
using namespace std;
int main(){
    char a='a';
    while(!cin.eof()){
        while(a != '\n'&&cin.get(a))
            cout<<a;
        a='a';
    }
    return 0;
}
Re:这代码能得到正确结果啊,怎么老是Time Limit Exceeded... 2012-01-19 20:53:53 bboybhappy
输入:
asdfsgdfg sdfgsdfg
sdfgsdfg sdfgsdg
sdfgsdg dfg !@#$
s

输出:
asdfsgdfg sdfgsdfg
sdfgsdfg sdfgsdg
sdfgsdg dfg !@#$
s

最后的[Enter]都正确啊...
Re:这代码能得到正确结果啊,怎么老是Time Limit Exceeded... 2012-01-19 21:06:27 bboybhappy
#include <iostream>
using namespace std;
int main(){
    char a;
    while(cin.get(a))
        cout<<a;
    return 0;
}
这个也行啊,还真是耗时太长吗.....
Re:这代码能得到正确结果啊,怎么老是Time Limit Exceeded... 2012-01-23 22:53:08 a4565219
用scanf,printf,比cin,cout快
Re:这代码能得到正确结果啊,怎么老是Time Limit... 2015-08-07 23:36:25 boring
为啥用scanf 和 printf 也不可以
----------------------------------------------------------------------------------
#include<stdlib.h>
#include<stdio.h>

int main()
{
    char c;

    while(scanf("%c",&c))
   
       printf("%c",c);
       
   return 0;
}
Reply
Title
Message
(64K)
University of Science and Technology of China
Online Judge for ACM/ICPC
Processed in 1.7ms with 1 query(s).