请编写函数proc(),该函数的功能是:将两个两位数的正整数num1,num2合并形成一个整数放在num中。合并的方式是:将num1数的十位和个位数依次放在num数的十位和千位上,num2数的十位和个位数依次放在c数的百位和个位上。
例如,当num1=64,num2=18时,调用到该函数后,num=4168。
注意:部分源程序给出如下。
请勿改动main()函数和其他函数中的任何内容,仅在函数proc()的花括号中填入所编写的若干语句。
试题程序:
第1题
请编写函数proc(),该函数的功能是:将两个两位数的正整数num1,num2合并形成一个整数放在num中。合并的方式是:将num1数的十位和个位数依次放在num数的十位和千位上,num2数的十位和个位数依次放在c数的百位和个位上。
例如,当num1=64,num2=18时,调用到该函数后,num=4168。
注意:部分源程序给出如下。
请勿改动main()函数和其他函数中的任何内容,仅在函数proc()的花括号中填入所编写的若干语句。
试题程序:
第2题
注意:请勿改动main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。
______________MyInterface
{
public static int NUM=100;
public abstract void print();
}
public class ClassName___________MyInterface
{
public void print()
{
System.out.println(NUM);
}
public static void main(String args[])
{
__________________________
obj .print();
}
}
第3题
请补充main函数,该函数的功能是:输入两个正整数numl和num2,求这两个数的最大公约和最小公倍数。
例如,若输入的两个正整数为12,4,则它们的最大公约数为12,最小公倍数为4。
注意:部分源程序给出如下。
请勿改动main函数和其他函数中的任何内容,仅在main函数的横线上填人所编写的若干表达式或语句。
试题程序:
include<stdlib.h>
include<stdio.h>
void main
{
int a,b,numl,num2,t;
system("CLS"):
printf("\nInput two numbers:\n");
scanf("%d,%d",&numl,&num2);
if(numl<num2)
{
a=num2;
b=num1:
}
else
{
a=num1;
b=num2;
}
while(【1】)
{
t=【2】
a=b;
b=t:
}
printf(“greatest common divisor:
%d\n",a);
printf("least common multiple:
%d\n",【3】;
}
第6题
注意:请勿改动main()主方法和其他已有的语句内容,仅在横线处填人适当的语句。
public class printNo3and5{
void print()
{
int n ;
for(n=100 ;n<=300 ;n++){
if(n%3==0)
__________
System.out.println(n);
}
}
public static__________main(String args[])
{
printNo3and5 bj=new printN03and5();
__________
}
}
第8题
注意:请勿修改main()主方法和其他已有语句内容,仅在横线处填入适当语句。
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class simple
{
public static void main{String[] args)
{
ExampleFrame. frame=new ExampleFrame();
frame.______(JFrame.EXIT_ON_CLOSE);
frame.show();
}
}
class ExampleFrame. extends JFrame
{
private JPanel panel;
public static final int DEFAULT_WIDTH=250;
public static final int DEFAULT_HEIGHT=250;
public ExampleFrame()
{
Init();
setTitle("welcome");
setSize(DEFAULT_WIDTH,DEFAULT_HEIGHT);
Container contentPane=getContentPane();
contentPane.add(panel);
}
private void init()
{
JLabel la1=new JLabel("输入整数a:");
JLabel la2=new JLabel ("输入整数b:");
final JTextField num1=new JTextField(10);
final JTextField num2=new JTextField(10);
JButton but=new JButton("计算");
final JLabel res=new JLabel("结果:");
but.addActionListener(______{
public void actionPerformed(ActionEvent event){
String str=new String();
String s1=num1.getText();
String s2=num2.getText();
try
{
int a=Integer.parseInt(s1);
int b=Integer.parseInt(s2);
str=String.valueOf(a +b);
}
catch(Exception e)
{
str=e.getMessage();
}
res.setText ("结果:"+str);
}
});
panel=new JPanel();
panel.setLayout(new FlowLayout(FlowLayout.LEFT));
panel.add(la1);
panel.add(num1);
panel.add(la2);
panel.add(hum2);
panel.add(but);
panel.add(res);
}
}
第9题
A.def product1(num): product=1 for i in range(1,num+1): product=product *i return product print(product1(10))
B.def sum1(num): sum2=0 for i in range(1,num+1): sum2+=i return sum2 print(sum1(100))
C.def product2(num): if num==1: return 1 else: return num *product2(num-1) print(product2(10))
D.def sum_a(num1): if num1==1: return 1 else: return num1+sum_a(num1-1) print(sum_a(100))
第10题
A.def product1(num): product=1 for i in range(1,num+1): product=product *i return product print(product1(10))
B.def sum1(num): sum2=0 for i in range(1,num+1): sum2+=i return sum2 print(sum1(100))
C.def product2(num): if num==1: return 1 else: return num *product2(num-1) print(product2(10))
D.def sum_a(num1): if num1==1: return 1 else: return num1+sum_a(num1-1) print(sum_a(100))
为了保护您的账号安全,请在“赏学吧”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!