明天要考试了,哪位老师教我做C语言题目?尽快

来源:百度知道 编辑:UC知道 时间:2024/05/17 23:01:13
程序填空题
tk485.c程序的功能是:将字符数组a中下标值为偶数的元素从小到大排列,其它元素不变。请将程序补充完整,使它能得出正确的结果。不得增行或删行,也不得更改程序的结构。

#include <stdio.h>
#include <string.h>
main()
{ char a[]="clanguage",t;
int i, j, k;
k=strlen(a);
for(i=0; i<=k-2; i+=2)
for(j=______; j<=k; j+=2 )
if( a[i]<a[j] )
{ t=a[i]; a[i]=a[j]; a[j]=t; }
puts(____);
printf("\n");
}
程序改错题
输入一个范围-32768——32767的整数,调用函数split(),拆解出各位的数字,放入字符数组s[]中。
正数前面加“+”号,负数前面加“-”号,零不加符号。
gc486.c程序有两处错误,请找出并修正,使之符合上述要求。不得增加行或删除行,也不得更改程序结构。
#include <stdio.h>
int main(void)
{
char s[7];
int k;
void split(int,char *);
printf("Please input a Integer( Range:-32768 to 32767 ):");
scanf("%d",&k);
split(k,s);
printf("%s\n",s);
return 0;
}
void split(int t,char *ps)
{
int i;
char *q=ps,tmp;
if (t>0)

#include <stdio.h>
#include <string.h>
main()
{ char a[]="clanguage",t;
int i, j, k;
k=strlen(a);
for(i=0; i<=k-2; i+=2)
for(j=i+2; j<=k; j+=2 )
if( a[i]<a[j] )
{ t=a[i]; a[i]=a[j]; a[j]=t; }
puts(a);
printf("\n");

}

#include <stdio.h>
#include <string.h>
void main()
{
char str[81],*p;
int wordnum=0;
printf("Please input an English sentence:");
gets(str);
puts(str);
p=str;
while(*p==32)
p = p + 1;
while(*p!='\0')
{
do
p++;
while( !(*p==' '||*p=='\0') );
wordnum++;
while(*p==32)
p++;
}
printf("There are %d words in the line\n",wordnum);
}

分太少,不做