更多"以下程序的功能是从键盘上输入若干个字符(以回车键作为结束)组成一个字符"的相关试题:
[简答题]【说明】
以下程序的功能是:从键盘上输入一个字符串,把该字符串中的小写字母转换为大写字母,输出到文件test.txt中,然后从该文件读出字符串并显示出来。
【程序】
#include < stdio. h >
main( )
FILE * fp;
char str[100]; int i=0;
if((fp=fopen("text.txt" (1) )) ==NULL)
printf("can’t open this file. /n") ;exit(0) ;
printf(" input astring: /n" ); gest(str);
while( str[i] )
if(str[i] >=’a’ && str[i] <=’z’)
str[i]= (2) ;
fputc(str[i], (3) );
i++;
fclose(fp);
fp=fopen(" test.txt", (4) );
fgets(str, 100, fp);
printf("%s/n" ,str);
(5) ;
[填空题]以下程序的功能是将字符串s中的数字字符放入d数组中,最后输出d中的字符串。例如,输入字符串 :abc123edf456gh,执行程序后输出:123456请填空.
#include <stdio.h>
#include <ctype.h>
main( )
char s[80], d[80]; int i,j;
gets(s);
for (i=j=0;s[i]!=’/0’;i++)
if( ) d[j]=s[i]; j++;
d[j]=’/0’;
puts (d);
[填空题]以下程序的功能是将字符串s中的数字字符放人d数组中,最后输出d中的字符串。例如,输入字符串abc123edf456gh,执行程序后输出123456。请填空。
# include<stdio. h>
# include<ctype. h>
main( )
{ char s[80], d[80]; int i, j;
gets(s);
for(i=j=0; s[i]!=’/0’; i++)
if( 【6】 ){ d[j]=s[i]; j++;)
d[j]=’/0’;
puts(D) ;
}
[填空题]以下程序的功能是将字符串s中的数字字符放入d数组中,最后输出d中的字符串。
例如,输入字符串:abc123edf456gh,执行程序后输出:123456。请填空。
#include <stdio.h>
#include <ctype.h>
main( )
{ char s[80],d[80]; int i,j;
gets(s);
for(i=j=0;s[i]! =’/0’;i++)
if( 【9】 ) {d[j]=s[i]; j++;}
d[j]=’/0’;
puts(d);
}
[填空题]以下程序的功能是将字符串s中的数字字符放入d数组中,最后输出d中的字符串。例如,输入字符串:abcl23edf456gh,执行程序后输出:123456。请填空。
#include <stdioo.h>
#include <ctype.h>
main( )
char s[80],d[80]; int i,j;
gets(s);
for(i=j=0;s[i]!=’/0’;i++)
if( 【20】 )d[j]=s[i];j++;
d[j]=’/0’;
puts(d);
[填空题]以下程序的功能是将字符串s中的数字字符放入d数组中,最后输出d中的字符串。例如,输入字符串:
abcl23edf456gh,执行程序后输出:123456。请填空。
#include<stdio.h>
#include<ctype,h>
main( )
char s[80],d[80];int i,j;
gets(s);
for(i=j=0;s[i]!=’/0’;i++)
if( 【20】 )d[j]=s[i];j++;
d[j]=’/0’;
puts(d) ;
[填空题]以下程序的功能是将字符串s中的数字字符放入d数组中,最后输出d中的字符串。例如,输入字符串:abc123edf456gh,执行程序后输出:123456。请填空。
#include <stdio.h>
#include <ctype.h>
main( )
{ char s[80], d[80]; int i,j;
gets(s);
for(i=j=0;s[i]!=’’/0’’;i++)
if(【 】) { d[j]=s[i]; j++; }
d[j]=’’/0’’;
puts(d);
}
[填空题]以下程序中函数 huiwen 的功能是检查一个字符串是否是回文,当字符串是回文时,函数返回字符串 yes!,否则函数返回字符串 no!,并在主函数中输出,所谓 回文即正向与反向的拼写都一样,例如:adgda。请填空。
#include
char *huiwen(char *str)
{ char *p1,*p2; int i,t=0;
p1=str;p2==_______ ;
for(i=0;i<=strlen(str)/2;i++)
if(*p1++!=*p2--){t=1;break;}
if(=_______ ) return("yes!");
}
main( )
else return("no!");
{ char str[50];
printf("Input:"); scanf("%s",str);
printf("%s/n",=_______ );
}
[填空题]以下程序中函数huiwen的功能是检查一个字符串是否是回文,当字符串是回文时,函数返回字符串yes!,否则函数返回字符串no!,并在主函数中输出,所谓回文即正向与反向的拼写都一样,例如:adgda。请填空。
#include<string.h>
char*huiwen (char*str)
{char*p1,*p2;int i,t=0;
p1=str;p2=【 】。
for(i=0;i<strlen(str)/2;i++)
if(*p1++!=*p2-){t=1;break;}
if(【 】)return("yes"!);
else return("no!");
}
main( )
{char str[50];
printf("Input:");scanf("%s",str);
printf("%s/n",【 】);
}