更多"以下程序的功能是;从键盘上输入一个大于等于3的整数,将其分解为质因子的"的相关试题:
[填空题]以下程序功能是输入一个学生的成绩,如果输入的成绩不在0~100之间,则显示出错信息。
main( )
{
int s;
scanf("%d",&s);
if(100>=s>=0)
printf("输入的成绩是%d/n",s);
else
printf("输入成绩出错");
}
错误:______
改正:______
[填空题]以下程序功能为仅接受输入Y或N,否则程序结束,请补充完整。
DO WHILE.T.
WAIT”请输入y/n”T0 YN
IF UPPER(YN)<>”N”
[]
ELSE
[8]
ENDIF
ENDDO
[填空题]以下程序的功能是:通过函数func输入字符并统计输入字符的个数。输入时用字符@作为输入结束标志。请填空。
#include <stdio.h>
long 【14】 ; /*函数说明语句*/
main( )
{ long n;
n=func( ); printf("n=%1d/n"n);
}
long func( )
{ long m;
for( m=0;getchar( )!=@ 【15】 ;
return m;
}
[填空题]
以下程序的功能是;从键盘输入一行字符串,将输入字符串中连续的数字作为一个整数,整数前的"+"和"_"分别表示正整数和负整数。依次取出相关的连续数字字符,并转换为整数后存放到整型数组中。函数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";
[填空题]以下程序完成的功能是输入一个数n,并判断它是否为素数,是或不是都通过消息对话框(MsgBox)来给出提示。请将程序补充完整。
Private Sub Cemmand1_Click( )
n = InputBox (“请输入一个整数”)
k = Int(Sqr(n))
i = 2
Flag = 0
do while i<= k And Flag = 0
if 【6】 = 0 then
Flag = 1
Else
i= i+ 1
End if
Loop
if 【7】 then
MsgBox “这是一个素数!”,vbOKOnly,“提示”
Else
MsgBox “这不是一个素数!”,vbOKOnly,“提示”
End if
End Sub
[填空题]以下程序的功能是从键盘上输入若干个字符(以回车键作为结束)组成一个字符串存入一个字符数组,然后输出该字符数组中的字符串。
main( )
char str[51],*sptr;
int i;
for(i=0;i<50;i++)
str[i]=getchar( );if(str [j]==’/n’)______;
str[i]:______;
sptr=str;
while(*sptr)putchar(*sptr______);
[填空题]以下程序的功能是:从键盘输入若干个学生的成绩,统计出最高成绩和最低成绩,当输入负数时结束输入。
#include<stdio.h>
main( )
float x,amax,amin;
scanf("%f",&x);
amax=x:
amin=x;
while( )/*第一空*/
if(______)amax=x;/*第二空*/
if(x<amin)______;/*第三空*/
scanf("%f",&x);
printf("amax=%3.2f,amin=%3.2f/n",amax,amin);
[填空题]以下程序的功能是:从键盘上输入若干个学生的成绩, 统计并输出最高成绩和最低成绩,当输入负数时结束输入.请填空.
main( )
{ float x,amax,amin;
scanf("%f",&x);
amax=x; amin=x;
while( )
{ if(x>amax) amax=x;
if( ) amin=x;
scanf("%f",&x); }
printf("/namax=%f/namin=%f/n",amax,amin); }
[填空题]以下程序的功能是从键盘上输入一行字符,存入一个字符数组中,然后输出该字符串。请填空。
main( )
char str[81],*sptr;
int i;
for(i=0;i<80;i++)
str[i]=getchar( );
if(str[i]==’/n’)break;
str[i]= 【10】 ;
sptr=str1
while(* sptr)putchar(* sptr 【11】 );
[填空题]以下程序的功能是从键盘输入若干个学生的考试成绩,统计并输出最高分和最低分,当输入负数时结束输入。请填空。
Private Sub Command1_Click( )
Dim x,amax,amin As Single
x=InputBox("Enter a score")
amax=x
amin=x
Do While______
If x>amax Then
amax=x
End If
If______Then
amin=x
End If
x=InputBox("enter a score")
Loop
Print "max=";amax,"min=";amin
End Sub
[填空题]以下程序的功能是,从键盘上输入若干学生的成绩,统计并输出最高分数和最低分数,当输入负数时结束输入,请填空。
Private Sub Command1_C1iek( )
Dim x As Single
Dim amax As Single,amln As Single
x=InputBox("请输入分数")
amax=x
amin=x
Do While 【8】
If x>amax Then
amax=x
End If
If 【9】 Then
amin=x
End If
x=InputBox("请输入分数")
Loop
Print amax,amin
End Sub
[填空题]以下程序的功能是:从键盘上输入若干个学生的考试分数,当输入负数时结束输入,然后输出其中的最高分数和最低分数。请在 【8】 和 【9】 处填入适当的内容,将程序补充完整。
Private Sub Form_Click( )
Dim x As Single,amax As Single,amin As Single
x=Input Box("Enter a score")
amax=X
amin=x
Do While 【8】
If x>ama x Then
Ama x=x
End lf
If 【9】 Then
amin=X
End lf
x=Input Box("Enter a score")
Loop
Print”Max=";amax,"Min=";amin
End Sub
[填空题]以下程序的功能是:从键盘上输入若干个数字,当输入负数时结束输入,统计出若干数字的平均值,显示结果。请填空。
Private Sub Form click( )
Dim x,y As Single
Dim z As Integer
x=Input Box (”Enter a score")
Do while 【13】
y=y + x
2=2+1
x=Input Box (”Enter a score")
Loop
if =0 Then
2=1
End lf
y=y/z
msgbox y
End Sub
[填空题]以下程序的功能是:从键盘上输入若干个数字,当输入负数时结束输入,统计出若干数字的平均值,输出结果。请填空。
Private Sub Form_click( )
Dim x,y As Single
Dim z As Integer
x=Input Box("Enter a score")
Do while 【8】
y=y+x
z=z+1
x=InputBox("Enter a score")
Loop
If z=0 Then
z=1
End If
y= 【9】
Print y
End Sub