程序中把表达式“a+0.5”写为“a*0.5”,是()错误。(A)编译(B)连接(C)运行(D)逻辑
程序中把表达式“a+0.5”写为“a*0.5”,是()错误。
(A)编译
(B)连接
(C)运行
(D)逻辑
程序中把表达式“a+0.5”写为“a*0.5”,是()错误。
(A)编译
(B)连接
(C)运行
(D)逻辑
下面程序把数组元素中的最大值放入a[o]中,则在if语句中的条件表达式应该是 () main() { int a[10]={6,7,2,9,1,10,5,8,4,3,},*p=a,i; for(i=0;i<10;i+ +,p+ +) if(____) *a=*p; printf("%d",*a); }
A.p>a
B.* p>a[0]
C.*p>* a [0]
D.* p [0]>* a [0]
请补充函数proc(),该函数的功能是把数组num中的数按从小到大的顺序排列(数组元素个数及值从主函数中输入)。
例如,输入n=5,num[0]~num[4]依次为5 7 2 8 0,结果为0 2 5 7 8。
注意:部分源程序给出如下。
请勿改动main()函数和其他函数中的任何内容,仅在函数proc()的横线上填入所编写的若干表达式或语句。
试题程序:
请补充函数fun(),该函数的功能是:把ASCII码为奇数的字符从字符串str中删除,结果仍然保存在字符串str中。字符串str从键盘输入,其长度作为参数传入函数fun()。
例如,输入“abcdef”,输出“bdf”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。
试题程序:
include <stdio.h>
define N 80
void fun(char s[],int n)
{
int i, j;
j=0;
for(i=0;【 】;i++)
{
if(【 】)
s [j++]-s [i];
}
【 】;
}
main ()
{
int i=0, strlen=0;
char str [N];
clrscr ();
printf ("\nInput a string: \n");
gets (str);
while (str [i] !='\0')
{
strlen++;
i++;
}
fun(str, strlen);
printf("\n*** display string ***\n");
puts (str);
}
请补充函数fun(),该函数的功能是:把ASCⅡ码为偶数的字符从字符串s打中删除,结果仍然保存在字符串srt中,字符串str从键盘输入,其长度作为参数传入函数fun()。
例如,输入“abcdef”,输出“ace”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。
试题程序:
inc lude< stdio, h>
define N 80
【 】
{
int i, j;
【 】
for (i=0;i<n;i++)
{
if (s [i] %2!=0)
s [j++]=s [i];
}
【 】;
}
main ()
{
int i=0, strlen=0;
char str[N];
clrscr ();
printf ("\nInput a string:\n");
gets (str);
while (str [i] !=' \0' )
{
strlen++;
i++;
}
fun (str, strlen);
printf("\n*** display string ***\n");
puts (str);
}
请补充函数fun(),该函数的功能是:把字符下标为非素数的字符从字符串sb中删除,把字符下标为素数的字符重新保存在字符串e口中。字符串sb从键盘输入,其长度作为参数传入函数fun()。
例如,输入“abcdefghijkl”,输出“cdfhl”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的横线上填入所编写的若干表达式或语句。
试题程序:
include <stdio.h>
define N 80
void fun(char s[],int n)
{
int i, j, k, flag;
【 】;
for(i=0; i<n; i++)
{
if (i>1)
s [k++] =s [i];
flag=I;
for(【 】; j<i&&flag; j++)
if (i%j==0)
{
flag=0;
【 】
}
}
s [k]='\0';
}
main()
{
int i=0, strlen=0;
char str[N];
clrscr ();
printf("\n Input a string:\n");
gets (str);
while (str [i] !='\0')
{
strlen++;
i++;
}
fun (str, strlen);
printf("\n*** display string ***\n");
puts (str);
}
为了保护您的账号安全,请在“简答题”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!