C语言遇到的问题 急急

来源:百度知道 编辑:UC知道 时间:2024/05/23 17:09:22
1, 填空,以下程序中,函数iseven的功能是判断一个整数是否为偶数。若是,贼返回1:否则,返回0
Int iseven(int x)
{ if(x%2)_______;
________;
}
Main()
{int n ;
Printf(“请输入测试的值”);
Scanf(“%d”,&n);
If(______) printf(“\n%d is even\n”,n);
else printf(“\n%d is odd\n”,n);
}
当输入数据12时,程序的输出结果是________。
2, 一下程序实现输入一串字符序列,以“#”结束。将其中的大写字母转换成小写字母输出,小写字母转换成大写字母输出,其余字符不输出。并累计其中的数字个数然后输出。请填空将程序补充完整。
#include <stdio.h>
Main()
{char c,a[100];
Int I=0,J=0,K=0;
While((c=getchar())!=_________)
{if (c>=’a’&&c<=’z’) a[J++]+________;
else if (c>=’A’&&c<=’Z’) a[J++]+________;
else if(________&&________)K++;}
for (I=0;I<J;I++)printf(“%c”,a{I});
printf(“\nThe number of digits is %d\n”,K);
}
3,以下程序实现从键盘上输入一个字符,用折半查找法找出该字符在已排序的字符串a中的位置。若字符不在,则打印**。请完善以下程序。
#include’ stdio.h”
#include”string.h”
Main()
{ chari str[100],ch;
Int bot=0,top,mid,flag=0;
ge

1.Int iseven(int x)
{ if(x%2__==0__)
__return 1__;
}
Main()
{
int n ;
Printf(“请输入测试的值”);
Scanf(“%d”,&n);
If(__iseven(n)__) printf(“\n%d is even\n”,n);
else printf(“\n%d is odd\n”,n);
}
当输入数据12时,程序的输出结果是____12 is even____。
2.#include <stdio.h>
Main()
{char c,a[100];
Int I=0,J=0,K=0;
While((c=getchar())!=__'#'___)
{if (c>=’a’&&c<=’z’) a[J++]+__c__;
else if (c>=’A’&&c<=’Z’) a[J++]+__c__;
else if(__c<'A'__&&__c>'z'__)K++;}
for (I=0;I<J;I++)printf(“%c”,a{I});
printf(“\nThe number of digits is %d\n”,K);
}
3.#include <string.h>
Main()
{ chari str[100],ch;
Int bot=0,top,mid,flag=0;
gets(str);
getchar(ch);
top=__strlen(str)__;
while((top-bot)>=0)
{mid=__(top-bot)/2__;
If(str[mid]= =c)
{___flag=1;___break;___}