更多"键盘输入字符串并在计算机屏幕上显示,这时的数据源是______。"的相关试题:
[填空题]键盘输入字符串并在计算机屏幕上显示,这时的数据源是______。
[填空题]键盘键入字符串并在计算机屏幕上显示,这时的数据源是【 】。
[填空题]键盘键入字符串并在计算机屏幕上显示,这时的数据源是 【13】 。
[填空题]以下程序运行时从键盘输入字符串ABCDE按回车键结束输入,使输入字符串中的A和B转换为字符#输出,其他字符输出为*。
#include"stdio.h"
main( )
{char c:
while((c=getchar( ))!=’/0’)
{switch(c)
{case’A’:
case’B’:putchar(’#’);break;
default:putchar(’*’);}
}
}
错误:______
改正:______
[填空题]
以下程序的功能是;从键盘输入一行字符串,将输入字符串中连续的数字作为一个整数,整数前的"+"和"_"分别表示正整数和负整数。依次取出相关的连续数字字符,并转换为整数后存放到整型数组中。函数change_int( )实现从字符串中依次取出整数并放入数组中
例如;输入字符串:"sf-123 abc+456 df7890j",则输出-123 456 7890
[程序](4分)
#include
void change_int(())
{
int flag;
count=0;
while(*p){
flag=1; //flag=1为正整数,flag=-1为负整数
while((*p<’0’||*p>’9’)&& ())p++;
if(*p==’-’){
flag=-1;
p++;
}
else if(*p==’+’) p++;
if(*p>=’0’ && *p<=’9’){
int num=0;
while(()){
num=num*10+*p-’0’;
p++;
}
num= () ;
b[count]=num;
count++;
}
}
}
void main(void)
{
char str[400];
int a[20],n;
cout<<"请输入一个含有数字的字符串;/n";
cin.getline(str,400);
change_int(str,a,n); ,
cout<<"输入字符串中共有"<个整数,它们分别是;/n";
[填空题]请补充main函数,该函数的功能是:从键盘输入一组字符串,以‘*’结束输入,并显示出这个字符串。
例如,输入abcdefghi*,结果显示adcdefghi。
注意:部分源程序给出如下.
请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio. h>
#define N 80
main ( )
{
iht i=-l, j=0;
char str IN];
clrscr ( );
printf("/n Input a string /n");
do
{
i++;
scanf(【1】);
}while(【2】);
printf ("/n**display the string** /n");
while (j<i)
{
printf (【3】);
j++;
}
}
[多项选择]填空题
请补充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
[填空题]下面程序的功能是对键盘输入的两个字符串进行比较,然后输出两个字符串中第一个不相同字符的ASCⅡ码之差。例如:输入的两个字符串分别为"abcdefg"和"abceef",则输出为-1。
#include <stdio.h>
main( )
char str1[100],str2[100],c;
int i,s;
printf("Enter string 1:");gets(str1);
printf("Enter string 2:");gets(str2);
i=0;
while((str1[i]==str2[i]&&str1[i]!=______))
i++;
s=______;
printf("%d/n",s);
[填空题]请补充main函数,该函数的功能是:从键盘输入一个字符串及一个指定字符,然后把这个字符及其后面的所有字符全部删除。结果仍然保存在原串中。
例如,输入“abcdef”,指定字符为‘e’,则输出“abcd”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include <stdio. h>
#define N 80
main ( )
{
int i=0;
char str [N];
char ch;
clrscr ( );
printf{"/n Input a string:/n");
gets (str);
printf("kn Input a charator;/n");
scanf ("%c", &ch);
while (str [i] !=’/0’)
{
if (str [i]==ch)
【1】
【2】 ;
}
str[i]= 【3】 ;
printf{"/n*** display string ***/n");
puts (str);
}