- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的代码的目的是从文本文件中读取多行文本,并且对于每一行,打印出“回文”,然后打印该文本行(如果它是回文)并打印出“非回文”和该行如果不是回文,则为文本。
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int palindrome(char str[])
{
int l=0;
int h = strlen(str) -1;
while (h>l)
{
if (str[l++] != str[h--])
{
printf("%s -> Not Palindrome",str);
return;
}
}
printf("%s is palindrome",str);
}
int main()
{
char str[100];
FILE*fptr;
fptr= fopen("Lab12input.txt","r");
if (fptr == NULL)
{
printf("can't open file");
exit(0);
}
while (fscanf(fptr,"%s",str) != EOF)
{
palindrome(str);
printf("\n");
}
fclose(fptr);
return 0;
}
最佳答案
uhh a %s
到 [fs]?scanf()
是一个以空格分隔的单词,它在空格字符处中断。 “逐句”指的是“逐行”,这就是 fgets()
的作用。
关于c - 为什么我的代码是逐字打印而不是逐句打印?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53679979/
我正在尝试返回数组“seats”,它本质上应该从文本文件返回数据 - 15x30 网格“#”。我已经尝试了很多东西,但我感到很沮丧,因为我对 java 的经验很少。我的代码可以编译,但在调用该方法时无
对于任何输入的字符串,我们需要按任意顺序的单词匹配来查找 super 字符串。即输入字符串中的所有单词必须以任何顺序出现在输出字符串中。例如给定数据集:“字符串搜索”“Java 字符串搜索”“手动 C
我有一个文本文件,其中包含一些我想放入二维数组中的内容。该文本文件由等长的句子组成。如何将每个单词放入数组? 文本文件的例子是- This is stackoverflow I am user 这个文
我正在编写一个实用程序,它接受一个 .resx 文件并创建一个包含 .resx 文件中所有名称/值对属性的 javascript 对象。这一切都很好,直到 .resx 中的值之一是 该经销商接受电子订
我输入了大量的数学表达式和方程式,我想为每个表达式和方程式打印出 latex 表示形式。到目前为止,我已经尝试过 Sage 和 sympy,但棘手的部分是不对表达式中的术语重新排序。 所以,如果我的输
我正在尝试通过实现异步任务在 android (java) 中流式传输 chatgpt api 的响应(逐字),但我收到错误。我正在将 java 的 HTTPurlconnection 库与输入和输出
我正在尝试通过实现异步任务在 android (java) 中流式传输 chatgpt api 的响应(逐字),但我收到错误。我正在将 java 的 HTTPurlconnection 库与输入和输出
我是一名优秀的程序员,十分优秀!