在我开始我的问题之前,我想声明几件事情: - 这不是本网站上已有问题的副本。 然而,在类似的线条上碰到一个问题,我仍然不明白输入输出是如何完成的。如在答复者说,代码有Codejam通过终端输入/输出问题
int main(int argc, int argv**)
{
}
但是,在网站上发布的解决方案,甚至没有使用。这个问题的例子是https://code.google.com/codejam/contest/1460488/dashboard#s=p0&a=0。 (用舌头说话,我使用ubuntu终端并试着按照How can I do file i/o without fstream for competitions like google code jam?的指示操作,发现没有任何东西写在输出文件中,我能更好地指导,如何实现,这不是作业,因为我已经做到了这一点我只需要知道如何做输入输出在Linux终端
林也给我的代码: - 。
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
#define DEBUG 1
#define printd if (DEBUG) printf
char cipher[26] = {'y', 'h', 'e', 's', 'o', 'c', 'v', 'x', 'd', 'u', 'i', 'g', 'l', 'b', 'k', 'r', 'z', 't', 'n', 'w', 'j', 'p', 'f', 'm', 'a', 'q'};
int main()
{
int count, j;
scanf("%d\n", &count);
for (j=0;j<count;j++)
{
printf("Case #%d: ",j+1);
translate();
printf("\n");
}
}
void translate()
{
char c;
scanf("%c", &c);
while (c != '\n')
{
if (c == ' ')
printf(" ");
else
{
int index = c - 'a';
if (index >=0 && index <= 26)
{
printf("%c", cipher[index]);
}
}
scanf("%c", &c);
}
}
三江源
如果性能是您的最终目标,我会推荐''fgetc()'在'scanf()'上的任何一天。 – WhozCraig 2013-04-07 19:24:50
那么,究竟是不是工作?你的代码做了什么以及你期望它做什么? – svick 2013-04-07 20:05:36
它本质上是一个翻译。有一个特定的映射,它接受来自文件的输入并根据映射将输出写入文件。这就是它所做的以及我期望它做的,只能通过linux终端。 – pranavsharma 2013-04-07 20:35:34