题目内容:
从键盘输入一组小写字母,保存在字符数组str中。请补充函数proc(),该函数的功能是:把字符数组str中字符下标为奇数的小写字母转换成对应的大写字母,结果仍保存在原数组中。例如,输入abcdefg,输出aBcDeFg。 注意:部分源程序给出如下。
请勿改动main()函数和其他函数中的任何内容,仅在函数proc()的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdlib h>
#include<stdio.h>
#define M 80
void proc(char str[])
{
int i=0;
while(【1】)
{
if(i%2!=c)
str[i]-=【2】 ;
【3】 ;
}
}
void main()
{
char str[M];
system("CLS");
printf("\n Input a string:\n");
gets(str);
printf("\n***original string ***\n");
puts(str);
proc(str);
printf("\n***new string***\n");
puts(str);
}
参考答案:
答案解析: