Open Lu-fm opened 4 years ago
发现了一个问题,数组不够大,可以改成全局变量搞大一点,但是还是过不了......
scanf("%s",str)
可以直接读入空格/tab/回车分隔的一个完整的单词,你直接这样读就可以了。
将一行读入 char str[N]
的方法是 scanf("%[^\n]\n",str)
。
自己写不太简单的读入是容易错的,一般就是 Runtime Error。把读入改了试试。
这是一个很好的技巧,可以在这里面看看https://blog.csdn.net/sunhaoyn/article/details/41347999
谢谢,学到了~
P1308 这个题在输入的时候被整了好久.....因为用gets不安全,一开始用scanf%s,最后用getchar吃掉回车,但是运行时却发现输入的时候s[0]和s[1]被跳过了,是从s[2]开始储存字符串.搞不懂所以用了getchar,自己运行没发现什么问题,但是洛谷上Runtime Error,不知道哪里有问题.求教.