更多"函数fun的功能是将s所指字符串中下标为偶数同时ASCII值为奇数的字"的相关试题:
[简答题]函数fun的功能是:将s所指字符串中ASCII值为奇数的字符删除,串中剩余字符形成一个新串放在t所指的数组中。
例如,若s所指字符串中的内容为:"ABCDEFG12345",其中字符A的ASCII码值为奇数、…、字符1的ASCII码值也为奇数、… 都应当删除,其它依此类推。最后t所指的数组中的内容应是:"BDF24"。
注意: 部分源程序存在文件PROG1.C中。
请勿改动主函数main和其它函数中的任何内容,仅在函数fun的花括号中填入你编写的若干语句。
给定源程序:
#include
#include
void fun(char *s, char t[])
{
}
main( )
{
char s[100], t[100];
printf("/nPlease enter string S:"); scanf("%s", s);
fun(s, t);
printf("/nThe result is: %s/n", t);
NONO( );
}
[简答题]函数fun的功能是:将s所指字符串中除下标为偶数同时ASCII码值也为偶数的字符外,其余的全部删除;字符串中剩余字符所形成的新串放在t所指的数组中。
例如,若s所指字符串中的内容为“ABCDEFG123456”,其中字符A的ASCII码值为奇数,因此应当删除;字符B的ASCII码值为偶数,但在数组中的下标为奇数,因此也应当删除;字符2的ASCII码值为偶数,在数组中的下标也为偶数,因此不应当删除,其他依此类推。最后t所指的数组中的内容应是“246”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入你编写的若干语句。
试题程序:
#include<stdio.h>
#include<string.h>
void fun(char*s,char t[])
voidmain( )
char s[100],t[100];
system("CLS");
printf("/nPlease enter string S:");
scanf("%s",s);
fun(s,t);
printf("/nThe result is:%s/n",t);
[简答题]函数fun( )的功能是:将s所指字符串中除了下标为奇数,同时ASCII值也为奇数的字符之外,其余的所有字符都删除,串中剩余字符所形成的一个新串放在t所指的数组中。
例如,若s所指字符串中的内容为“ABCDEFG12345”,其中字符A的ASCII码值虽为奇数,但所在数组中的下标为偶数,因此必须删除;而字符1的ASCII码值为奇数,所在数组中的下标也为奇数,因此不应当删除,其他以此类推。最后t所指数组中的内容应是“135”。
#include<stdio.h>
#include<string.h>
void fun(char *s,char t[])
main( )
char s[100],t[100];void NONO( );
printf("/nPlease enter string s:");scanf("%s",s);
fun(s,t);
printf("/nThe result is:%s/n",t);
NONO( );
[简答题]请编写函数fun( ),其功能是将s所指字符串中除了下标为奇数、同时ASCII值也为奇数的字符之外,其余的所有字符都删除。字符串中剩余的字符所形成的一个新的字符串放在t所指的数组中。
例如:s所指字符串中的内容为ABCDEFG12345,其中字符A,的ASCII码值虽为奇数,但元素所在的下标为偶数,因此必需删除;字符1的ASCII码值为奇数,所在数组中的下标也为奇数,不删除,最后t所指的数组中的内容应是135。
请勿修改主函数main和其他函数中的任何内容,仅在函数su的花括号中填写若干语句。
文件test 27_2.cpp的内容如下;
#include <conio.h>
#include <stdio.h>
#include <iostream.h>
#include <string.h>
void fun(char *s,char t[ ])
void main ( )
char s[100],t[100];
cout<<"Please enter string S: "<<end1;
gets(s);
fun(s, t);
puts(t);
[简答题]请编写函数fun( ),其功能是:将s所指字符串中除了下标为偶数、同时ASCII码值为奇数的字符之外,其余的所有字符都删除,串中剩余字符所形成的一个新串放在t所指的数组中。
例如,若s所指字符串中的内容为ABCDEFG12345,其中字符B的ASCII码值为偶数,所在元素的下标为奇数,因此必须删除;而字符A的ASCII码值为奇数,所在数组中的下标为偶数,因此不应当删除,其他依次类推。最后t所指的数组中的内容应是ACEG。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
#include<conio.h>
#include<stdio.h>
#include<string.h)
void fun(char *s, char t[])
{
}
main( )
{
char s[100],t[100];
clrscr( );
printf("/nPlease enter string s:");
scanf("%s",s);
fun(s,t);
printf("/nThe result is: %s/n",t);
}
[简答题]请编写函数fun( ),其功能是:将s所指字符串中除了下标为奇数、同时ASCII值为偶数的字符外,其余的全部删除,串中剩余字符所形成的一个新串放在t所指的数组中。
例如,若s所指字符串中的内容为edB2A4Dsdg,其中字符A的ASCII码值为奇数,因此应当删除;其中字符B的ASCII码值为偶数,但在数组中的下标为偶数,因此也应当删除:而字符2的ASCII码值为偶数,所在数组中的下标为奇数,因此不应当删除,其他依此类推。最后t所指的数组中的内容应是d24。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
#include <conio.h>
#include <stdio.h>
#include<string, h>
void fun(char*s, char t[])
{
}
main( )
{
char s[100] ,t[100];
clrscr( );
printf("/nPlease enter string S: ");
scanf("%s",s);
fun(s,t);
printf("/nThe result is: %s/n",t);
}
[简答题]请编写函数fun( ),其功能是:将s所指字符串中除了下标为偶数、同时ASCII值也为偶数的字符外,其余的全部删除,串中剩余字符所形成的一个新中放在t所指的数组中。
例如,若s所指字符串中的内容为ABCDEFG123456,其中字符A的ASCII码值为奇数,因此应当删除;其中字符B的 ASCII码值为偶数,但在数组中的下标为奇数,因此也应当删除;而字符2的ASCII码值为偶数,所在数组中的下标也为偶数,因此不应当删除,其他依此类推。最后t所指的数组中的内容应是246。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
#include<conio.h>
#include<stdio.h>
#include<string.h>
void fun(char*s,char t[])
{
}
main( )
{
char s[100],t[100];
clrscr( );
printf("/nPlease enter string S:");
scanf("%s",s);
fun(s,t);
printf("/nThe result is:%s/n",t);
}
[填空题]给定程序MODI1.C中函数fun的功能是:将s所指字符串中位于奇数位置的字符或ASCII码为偶数的字符放入t所指数组中(规定第一个字符放在第0位中)。
例如,字符串s中的数据为:AABBCCDDEEFF,则字符串t中的数据为:ABBCDDEFF。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
文件MODI1.C内容如下:
#include<stdio.h>
#include<string.h>
#define N 80
void fun(char *s,char t[])
int i,j=0,n;
n=strlen(s);
for(i=0;i<n;i++)
/**********found**********/
if(i%2&&s[i]%2==0)t[j++]=s[i];
/**********found**********/
t[i]=’/0’;
void main( )
char s[N],t[N];
printf("/nPlease enter string s:");
gets(s);
fun(s,t);
printf("/nThe result is: %s/n",t);
[填空题]给定的程序中,fun函数的功能是:将s所指字符串中除了下标为偶数,同时ASCH值为偶数的字符除外,其余的全部删除;串中剩余字符所形成的一个新串放在t所指的数组中。如:若s所指字符串中的内容为:”desktop12345",t所指字符串中的内容为:"dtp24"。
请在程序的下划线处填写正确的内容,使程序得到正确的结果。
#inClUde <conio.h>
#include <stdio.h>
#include <string.h>
void fun (Char *s,char t[])
{
int i,j;
for(i=0,j=0; (1) ;i++)
if(i%2==0&&s[i]%2==0) (2) ;
(3) ;
}
main( )
{ char s[100],t[100];
clrscr( );
printf("/nPlease enter string S:");
scanf("%s",s);
fun(s,t);
printf("/n The result is:% s/n",t);
NONO( );/*本函数与考生答题无关,考生不得改动,否则后果自负。*/
}
[填空题]请补充函数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;
【1】 ;
for(i=0; i<n; i++)
if (i>1)
s [k++] =s [i];
flag=I;
for( 【2】 ; j<i&&flag; j++)
if (i%j==0)
flag=0;
【3】
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);
[简答题]给定程序MODI1.C中函数 fun 的功能是:将s所指字符串中最后一次出现的与t1所指字符串相同的子串替换成t2所指字符串,所形成的新串放在w所指的数组中。在此处,要求t1和t2所指字符串的长度相同。
例如,当s所指字符串中的内容为:"abcdabfabc",t1所指子串中的内容为:
"ab",t2所指子串中的内容为:"99"时, 结果,在w所指的数组中的内容应为:
"abcdabf99c"。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构!
给定源程序:
#include
#include
int fun (char *s, char *t1, char *t2 , char *w)
{
int i; char *p , *r, *a;
strcpy( w, s );
/************found************/
while ( w )
{ p = w; r = t1;
while ( *r )
/************found************/
IF ( *r == *p )
{ r++; p++; }
else break;
if ( *r == ’/0’ ) a = w;
w++;
}
r = t2;
while ( *r ){ *a = *r; a++; r++; }
}
main( )
{
char s[100], t1[100], t2[100], w[100];
printf("/nPlease enter string S:"); scanf("%s", s);
printf("/nPlease enter substring t1:"); scanf("%s", t1);
printf("/nPlease enter substring t2:"); scanf("%s", t2);
if ( strlen(t1)==strlen(t2) )
{ fun( s, t1, t2, w);
printf("/nThe result is : %s/n", w);
}
else printf("/nError : strlen(t1) != strlen(t2)/n");
}
[填空题]以下函数 sstrcat( )的功能是实现字符串的连接,即将 t 所指字符串复制到 s 所指 字符串的尾部。例如:s 所指字符串为 abcd,t 所指字符串为 efgh,函数调用后
s 所指字符串为 abcdefgh。请填空。
#include
void sstrcat(char *s,char *t)
{ int n;
n=strlen(s);
while(*(s+n)=_________){s++; t++;}
}
[填空题]以下sstrcpy( )函数实现字符串复制,即将t所指字符串复制到s所指内存空间中,形成一个新字符串s。请填空。
void sstrcpy(char *s,char *t)
{ while( *s++= 【13】 );}
main( )
{ char strl[100],str2[]="abcdefgh";
sstrcpy(str1,str2);
printf("%s/n",str1);
}
[填空题]以下函数sstrcat的功能是实现字符串的连接,即将t所指字符串复制到s所指字符串的尾部。例如:,所指字符串为abed,t所指字符串为efgh,调用函数sstrcat后s所指字符串为 abcdefgh。请填空。
#inehde <stdio.h>
#include <string.h>
void sstuat(char * 9,char *t)
int n;
n = strlen (s);
while(*(s+n) = 【14】 )s++; t++;