下面程序的功能是实现字符串逆序存放。
程序运行结果如下:
Input a string:ABCDEFGHI↙
Inversed results:IHGFEDCBA
按要求在空白处填写适当的表达式或语句,使程序完整并符合题目要求。
#include
#include
#define N 80
void Inverse(char *pStr);
int main()
{
char a[N];
printf("Input a string:");
gets(a);
Inverse(a);
printf("Inversed results:%s\n", a);
return 0;
}
/* 函数功能: 实现将字符数组中的字符串逆序存放 */
void Inverse(____________)
{
int len;
char temp;
char *pStart; /* 指针变量pStart指向字符串的第一个字符 */
char *pEnd; /* 指针变量pEnd指向字符串的最后一个字符 */
len = strlen(pStr); /* 求出字符串长度 */
for (pStart=pStr,___________; pStart {
temp = *pStart;
______________;
*pEnd = temp;
}
}
A、第16行: char *pStr
第23行: pEnd=pStr+len-1
pEnd--
第26行: *pStart = *pEnd
B、第16行: char pStr
第23行: pEnd=pStr+len
pEnd--
第26行: *pStart = *pEnd
C、第16行: char *pStr
第23行: pEnd=pStr+len-1
pEnd++
第26行: pStart = pEnd
D、第16行: char pStr
第23行: pEnd=pStr+len+1
pEnd++
第26行: *pStart = *pEnd
程序运行结果如下:
Input a string:ABCDEFGHI↙
Inversed results:IHGFEDCBA
按要求在空白处填写适当的表达式或语句,使程序完整并符合题目要求。
#include
#include
#define N 80
void Inverse(char *pStr);
int main()
{
char a[N];
printf("Input a string:");
gets(a);
Inverse(a);
printf("Inversed results:%s\n", a);
return 0;
}
/* 函数功能: 实现将字符数组中的字符串逆序存放 */
void Inverse(____________)
{
int len;
char temp;
char *pStart; /* 指针变量pStart指向字符串的第一个字符 */
char *pEnd; /* 指针变量pEnd指向字符串的最后一个字符 */
len = strlen(pStr); /* 求出字符串长度 */
for (pStart=pStr,___________; pStart
temp = *pStart;
______________;
*pEnd = temp;
}
}
A、第16行: char *pStr
第23行: pEnd=pStr+len-1
pEnd--
第26行: *pStart = *pEnd
B、第16行: char pStr
第23行: pEnd=pStr+len
pEnd--
第26行: *pStart = *pEnd
C、第16行: char *pStr
第23行: pEnd=pStr+len-1
pEnd++
第26行: pStart = pEnd
D、第16行: char pStr
第23行: pEnd=pStr+len+1
pEnd++
第26行: *pStart = *pEnd
C语言程序设计精髓