第一题输出 6 7 8 9 10
函数将第0个元素等于第5个(相对传入的数组开始的元素来算),因此0-4就是5-9
第二题输出 54
就是2+3+...+10
total=oddadd(a+1,9); 好像应该是错误句法,怎么通过编译的就不知道了。
change(); n<5时不会出错吧?k[0] = k[5]; 是个什么算法?
能否把算法意图、算法说明讲解一下?算法不该乱作。
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
void main() {
char str[100];
printf("请输入一行文字\n");
fgets(str, 100, stdin);
int space = 0;
int litter = 0;
int litters = 0;
int num = 0;
int other = 0;
for (char* p = str; *p != '\0';++p) {
if (*p == ' ') {
space += 1;
}
else if (*p > 64 && *p < 91) { //大写字母 ASCII 64~91
litter += 1;
}
else if (*p > 97 && *p < 122) { //小写字母 ASCII 97~122
litters += 1;
}
else if (*p > 47 && *p < 58) { //数字 ASCII 0~9
num += 1;
}
else {
if (*p != '\n') {//fgets()函数会在末尾自动加上\n,需要判断是否为换行符
other += 1;
}
}
}
printf("空格的个数:%d\n", space);
printf("大写英文字母个数:%d\n", litter);
printf("小写英文字母个数:%d\n", litters);
printf("数字的个数为:%d\n", num);
printf("其他字符的个数:%d\n", other);
}
答案:
很抱歉,问题描述过于宽泛,没有具体的C语言问题需要解答。参考资料中提到了一些C语言的基础概念和代码解析,可以帮助初学者更好地理解C语言的运算优先级、栈、递归等概念和编程方法。如果有具体的问题需要解答,请提供更加详细的问题描述。