更多"请补充main 函数,该函数的功能是:先以只写方式打开文件“out99"的相关试题:
[填空题]请补充main 函数,该函数的功能是:先以只写方式打开文件“out99.dat”,再把字符串str中的字符保存到这个磁盘文件中。
注意:部分源程序给出如下。
请勿改动主函数main 和其他函数中的任何内容,仅在 main 函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include "stdio. h"
#include "conio.h"
#define N 80
main ( )
FILE *fp;
int i=0;
char ch;
char str[N]="I’m a student!";
clrscr( );
if ( (fp=fopen ( 【1】 ) ) ==NULL)
printf("cannot open out99. dat/n");
exit(0);
while (str[i])
ch=str[i];
【2】 ;
putchar(ch);
i++;
【3】 ;
[填空题]请补充main( )函数,该函数的功能是:先以只写方式打开文件file.dat,再把字符串s中的字符保存到这个磁盘文件中。请勿改动main( )函数与其他函数中的任何内容,仅在的横线上填写所需的若干表达式或语句。
注意:部分源程序给出如下。
试题程序:
#include<stdlib.h>
#include<stdio.h>
#define N 100
void main( )
{
FILE*f;
int i=0;
char ch;
chair s[N]="Welcome!";
if((f=fopen|("______", "w"))==NULL)
{
printf("cartnot open file.dat/n");
exit(0);
}
while(s[i])
{
ch=s[i];
______;
putchar(ch);
i++;
}
______;
}
[填空题]请补充main( )函数,该函数的功能是:从键盘输入一个字符串并保存在字符str1中,把字符串str1中下标为偶数的字符保存在字符串str2中并输出。例如,当str1="computer",则str2="cmue"。
注意:部分源程序给出如下。
请勿改动函数中的任何内容,仅在横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdlib.h>
#include<stdio.h>
#include<conio.h>
#define LEN 80
void main( )
{
char str1[LEN],str2[LEN];
char*p1=str1,*p2=str2;
int i=0,j=0;
system("CLS");
printf("Enter the string:/n");
scanf(______);
printf("***the origial string***/n");
while(*(p1+j))
{
printf("______",*(p1+j));
j++;
}
for(i=0;i<j;i+=2)
*p2++=*(str1+i);
*p2="/0";
printf("/nThe new string is:%s/n",______);
}
[填空题]请补充main函数,该函数的功能是:从键盘输入一个字符串并保存在字符str1中,把字符串str1中下标为偶数的字符保存在字符串str2中并输出。例如,当str1=“cdefghij”,则 str2=“cegi”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun( )的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#include<conio.h>
#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<j;i+=2)
*p2++=*(str1+i);
*p2=’/0’;
printf("/nThe new string is:%s/n", 【3】 );
[填空题]请补充main函数,该函数的功能是:把字符串str中的字符向前移动一位,原来的第一个字符移动到字符串尾,结果仍然保存在原字符串中。
例如,输入“how do you do”,则结果输出“ow do you doh”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include <stdio. h>
#define N 80
main( )
char str[N], ch;
int i;
clrscr ( );
printf("/n Input a string:In");
gets (str);
printf("/n*** original string ***In");
puts (str);
ch=str [0];
for (i=0; 【1】 ; i++)
str [i]=str [i+1];
【2】 ;
printf("/n *** new string ***/n");
puts (str);
[填空题]请补充main函数,该函数的功能是:从字符串str中取出所有数字字符,并分别计数,然后把结果保存在数组b中并输出,把其他字符保存在N[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 <stdio.h>
#include <conio.h>
main( )
int i,b[11];
char *str="abl23456789cde090";
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;
[多项选择]填空题
请补充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
[填空题]请补充main函数,该函数的功能是:从一个字符串中截取前面若干个给定长度的子字符串。其中,str1指向原字符串,截取后的字符存放在str2所指的字符数组中,n中存放需截取的字符个数。
例如:当str1=“cdefghij”,然后输入4,则str2=“cdef”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun( )的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#include<conio.h>
#define LEN 80
main( )
char str1[LEN],str2[LEN];
int n,i;
clrscr( );
printf("Enter the string:/n");
gets(str1);
printf "Enter the position of the string deleted:");
scanf( 【1】 );
for(i=0;i<n;i++)
【2】
str2[i]=‘/0’;
printf("The new string is:%s/n", 【3】 );
[填空题]请补充main函数,该函数的功能是:从键盘输入两上字符串并分别保存在字符数组str1和str2中,用字符串str2替换字符串str1前面的所有字符,注意,str2的K度不大于str1,否则需要重新输入。
例如,如果输入strl;=“abced”,str2=“fk”,则输出“fkced”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仪在 main函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#include<string. h>
main ( )
char strl [ 81], str2 [ 81 ];
char *pl=strl, *p2=str2;
clrscr ( );
do
printf(" Input strl tn");
gets (strl);
printf(" Input str2 In");
gets (str2);
while(【1】);
while(【2】)
*p1++=*p2++;
printf(" Display strl /n");
puts (【3】)
[填空题]请补充函数fun( ),该函数的功能是:把从主函数中输入的字符串str2接在字符串str1的后面。
例如:str1=“How do”,str2=“you do”,结果输出:How do you do
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#include<conio.h>
#define N 40
void fun(char *str1,char *str2)
int i=0;
char *p1=str1;
char *p2=str2;
while( 【1】 )
i++;
for( ; 【2】 ;i++)
*(p1+i)= 【3】 ;
*(p1+i)=’/0’;
main( )
char str1[N],str2[N);
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( ),该函数的功能是:把从主函数中输入的字符串str2倒置后接在字符串str1后面。
例如:str1=“How do”,str2=“od uoy”,结果输出:“How do you do”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun( )的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#include<conio.h>
#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");
p
[填空题]请补充main函数,该函数的功能是:把一个字符串中的所有小写字母字符全部转换成大写字母字符,其他字符不变,结果保存原来的字符串中。
例如:当str[N]“123 abcdef ABCDEF!”,结果输出:
“123ABCDEFABCDEF!”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#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");
[简答题]填空题
请补充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");
}
[填空题]请补充main( )函数,该函数的功能是:把一个二维字符数组每行字符串中最大的字符复制到字符数组s中。
例如,如果arr[3]="hoih", "yufui", "xgf",则str="oyx"。
注意:部分源程序已给出。
请勿改动主函数main和其他函数中的任何内容。
试题程序:
#include<stdlib.h>
#include<stdio.h>
void main( )
int i=0;
char *arr[3]="hoih", "yufui", "xgf";
char **p;
char str[8];
system("CLS");
(1) ;
for(i=0; i<3; i++)
str[i]= *p[i];
while(* p[i])
if (str[i]<*p[i])
str[i]=*p[i];
(2) ;
(3) ;
printf("new string/n");
puts(str);