一道 Compilation error 问题(uva458)
题目是uva458。IO输入字符串,若不为回车则输出每一个字符ASC2码减7的字符;否则输出回车。这两段程序在Dev-C++ 4.9.9.0用自己的数据测试都没问题;评测结果分别是编译错误(Compilation error)和Accepted。请帮忙看看前面这一段程序为什么编译错误。谢谢~
#include <iostream>
using namespace std;
int main(){
char c;
while((c=cin.get())!=EOF){
if(c != '\n') cout.put(c-7);
else cout.put(c);
}
//system("pause");
return 0;
}
//Compilation error
下面这一段是AC。
#include <stdio.h>
int main(){
char c;
while ((c = getchar()) != EOF)
if (c != '\n') putchar(c-7);
else putchar(c);
//getchar();
return 0;
}