更多"填空题
请补充函数fun( ),该函数的功能是:把一个整数转换成字符"的相关试题:
[多项选择]填空题
请补充main函数,该函数的功能是:从键盘输入一个字符串并保存在字符str1中,把字符串str1中下标为偶数的字符保存在字符串str2中并输出。例如,当str1=“cdefghij”,则str2=“cegi”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun( )的横线上填入所编写的若干表达式或语句。
试题程序:
#include
#include
#define LEN 80
main( )
{
char str1[LEN],str2[LEN];
char *p1=str1,*p2=str2;
int i=0,j=0;
clrscr( );
printf("Enter the string:/n");
scanf(【1】);
printf("***the origial string***/n");
while(*(p1+j))
{
printf("【2】",*(p1+j));
j++;
}
for(i=0;i
[简答题]填空题
请补充函数fun( ),该函数的功能是:把从主函数中输入的字符串str2倒置后接在字符串str1后面。
例如:str1=“How do”,str2=“od uoy”,结果输出:“How do you do”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun( )的横线上填入所编写的若干表达式或语句。
试题程序:
#include
#include
#define N 40
void fun(char *str1,char *str2)
{
int i=0,j=0,k=0,n;
char ch;
char *p1=str1;
char *p2=str2;
while(*(p1+i))
i++;
while(*(p2+j))
j++;
n=【1】;
for(;k<=j/2;k++,j--)
{
ch=*(p2+k);
*(p2+k)=*(p2+j);
*(p2+j)=ch;
}
【2】;
for(;【3】;i++)
*(p1+i)=*p2++;
*(p1+i)=’’/0’’;
}
main( )
{
char str1[N],str2[N];
int m,n,k;
clrscr( );
printf("***Input the string str1 & str2
***/n");
printf("/nstr1:");
gets(str1);
printf("/nstr2:");
gets(str2);
printf("*** The string str1 & str2 ***/n");
puts(str1);
puts(str2);
fun(str1,str2);
printf("*** The new string ***/n");
puts(str1);
}
[简答题]填空题
请补充函数fun( ),该函数的功能是:把字符串str中的字符按字符的ASCII码降序排列,处理后的字符串仍然保存在原串中,字符串及其长度作为函数参数传入。
例如,如果输入“cdefgh”,则输出为“hgfedc”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun( )的横线上填入所编写的若干表达式或语句。
试题程序:
#include
#define N 80
void fun(char s[],int n)
{
int i, j;
char ch;
for(i=0;i
[简答题]填空题
str是一个由数字和字母字符组成的字符串,由变量num传入字符串长度。请补充函数fun( ),该函数的功能是:把字符串str中的数字字符转换成数字并存放到整型数组bb中,函数返回数组bb的长度。
例如:str=“Bcd123e456hui890”,结果为:123456890。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun( )的横线上填入所编写的若干表达式或语句。
试题程序:
#include
#define N 80
int bb[N];
int fun(char s[],int bb[],int num)
{
int i,n=0;
for(i=0;i
[简答题]填空题
请补充main函数,该函数的功能是:把一个字符串中的所有小写字母字符全部转换成大写字母字符,其他字符不变,结果保存原来的字符串中。
例如:当str[N]=“123 abcdef ABCDEF!”,结果输出:“123 ABCDEF ABCDEF!”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的横线上填入所编写的若干表达式或语句。
试题程序:
#include
#include
#include
#define N 80
void main( )
{
int j;
char str[N]=" 123abcdef ABCDEF!";
char *pf=str;
clrscr( );
printf("***original string ***/n");
puts(str);
【1】;
while(*(pf+j))
{
if(*(pf+j)>=’’a’’&&*(pf+j)<=’’z’’)
{
*(pf+j)=【2】;
j++;
}
else
【3】;
}
printf("******new string******/n");
puts(str);
system("pause");
}
[简答题]填空题
请补充函数fun( ),该函数的功能是:按‘0’到‘9’统计一个字符串中的奇数数字字符各自出现的次数,结果保存在数组num中。注意:不能使用字符串库函数。
例如:输入“x=112385713.456+0.909*bc”,结果为:1=3,3=2,5=2,7=1,9=2。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun( )的横线上填入所编写的若干表达式或语句。
试题程序:
#include
#define N 1000
void fun(char *tt,int num[])
{
int i,j;
int bb[10];
char *p=tt;
for(i=0;i<10;i++)
{
num[i]=0;
bb[i]=0;
}
while(【1】)
{
if(*p>=’’0’’&&*p<=’’9’’)
【2】;
p++;
}
for(i=1,j=0;i<10;i=i+2,j++)
【3】;
}
main( )
{
char str[N];
int num[10],k;
clrscr( );
printf("/nPlease enter a char string:");
gets(str);
printf("/n**The original string**/n");
puts(str);
fun(str,num);
printf("/n**The number of letter**/n");
for(k=0;k<5;k++)
{
printf("/n");
printf("%d=%d",2*k+1,num[k]);
}
printf("/n");
return;
}
[填空题]请补充函数fun( ),该函数的功能是:把一个整数转换成字符串,并倒序保存在字符数组str中。例如:当n=13572468时,str=-“86427531”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的横线上填入所编写的若干表达式或语句。
试题程序:
#include <stdio.h>
#include <conio.h>
#define N 80
char str[N];
void fun(long int n)
int i=0;
while( 【1】 )
str[i]= 【2】 ;
n/=10;
i++;
【3】 ;
main( )
long int n=13572468;
clrscr( );
printf("*** the origial data ***/n");
printf("n=%ld",n);
fun(n);
printf("/n%s",str);
[简答题]填空题
请补充main函数,该函数的功能是:从字符串str中取出所有数字字符,并分别计数,然后把结果保存在数组b中并输出,把其他字符保存在b[10]中。
例如:当str1=“ab123456789cde090”时,结果为:
0:2 1:1 2:1 3:1 4:1 5:1 6:1 7:1 8:1 9:2 other charactor:5
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun( )的横线上填入所编写的若干表达式或语句。
试题程序:
#include
#include
main( )
{
int i,b[11];
char *str="ab123456789cde090";
char *p=str;
clrscr( );
printf("*** the origial data ***/n");
puts(str);
for(i=0;i<11;i++)
b[i]=0;
while(*p)
{
switch(【1】)
{
case ’’0’’:b[0]++;break;
case ’’1’’:b[1]++;break;
case ’’2’’:b[2]++;break;
case ’’3’’:b[3]++;break;
case ’’4’’:b[4]++;break;
case ’’5’’:b[5]++;break;
case ’’6’’:b[6]++;break;
case ’’7’’:b[7]++;break;
case ’’8’’:b[8]++;break;
case ’’9’’:b[9]++;break;
【2】
}
【3】
}
printf("****** the result ********/n");
for(i=0;i<10;i++)
printf("/n%d:%d",i,b[i]);
printf("/nother charactor:%d",b[i]);
}
[填空题]请补充函数proc( ),该函数的功能是:把一个整数转换成字符串,并倒序保存在字符数组str中。例如,当n=12345时,str="54021"。
注意:部分源程序给出如下。
请勿改动main( )函数和其他函数中的任何内容,仅在函数proc( )的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdlib.h>
#include<stdio.h>
#include<conio.h>
#define M 100
char str[M];
void proc(long int n)
{
int i=0;
while(______)
{
str[i]=______;
n/=10;
i++;
}
______;
}
void main( )
{
long int n=12345;
system("CLS");
printf("***the origial data***/n");
printf("n=%1d",n);
proc(n);
printf("/n%s",str);
}
[填空题]请补充fun函数,该函数的功能是:把一个整数转换成字符串,并倒序保存在字符数组S中。例如,当n=123时,s="321"。
注意:部分源程序已给出。
淆勿改动主函数main和其他函数中的任何内容,仅在main函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#include<conio.h>
#define M 80
char s[M];
void fun(long int n)
int j=0;
while( (1) )
s[j]= (2) ;
n/=10;
j++;
(3) ;
main( )
long int n=1234567;
printf("The origial data/n");
printf("n=%1d",n);
fun(n);
printf("/n%s",s);