C语言的题,哪个大大帮我做完,谢谢啊,还有追加分,尽量写详细点,

来源:百度知道 编辑:UC知道 时间:2024/09/13 10:06:27
第一套 上机训练试题

一.填空题
1.下列给定程序中,函数fun()的作用是:将字符串tt中的大写字母都改为对应的小写字母,其他字符不变。例如,若输入“Ab, c D”,则输出“ab,cd”。
试题程序:

#include <stdio.h>
#include <string.h>
#include <conio.h>
fun (char tt[ ])
{
int i;
for(i=0;tt[i];i++)
{
if((tt[i]>=’A’)&&(tt[i]<= )
tt[i]+=32;
}
}
main()
{
char tt[81];
printf(“\nPlease enter a string :”);
gets(tt); fun(tt);
printf(“\nThe result string :\n%s”, );
}

2.改错题
下列给定程序中,函数fun()的功能是逐个比较a,b两个字符串对应位置中的字符,把ASCII值小或相等的字符依次存放到c数组中,形成一个新的字符串。
例如:a中的字符串为fshADfg, b中的字符串为sdAEdi,则c中的字符串应为fdAADf.
请改正程序中的错误,使它能得到正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序中的结构。
试题程序:

#include <stdio.h>
#include <string.h>
void fun(char p[],char q[],char c[])
{ int i=0,j=0,k=0;
while(p[i]!=’\0’||q[j]!=’\0’)
/*********found***********/

1. if((tt[i]>=’A’)&&(tt[i]<= 'Z')
2.
if(p[i]<=q[j]) c[k]=p[j];
else c[k]=q[i];

if(p[i]>=q[j]) c[k]=q[j];
else c[k]=p[i];

3.
long fun(int a,int b)
{long c;

int num1,num2;
num1=a%10;
num2=a/10
c=num1*10+num2;
num1=b%10;
num2=b/10;
c+=num1*1000+num2*100;
return c;

}

1
if((tt[i]>=’A’)&&(tt[i]<='Z' )
2
把if(p[i]<=q[j]) 改成if(p[i]>=q[j])
3
填入:
c=(b%10)*1000+(b/10)*100+(a%10)*10+(a/10);
return c;