更多"阅读以下说明和C程序代码,将程序补充完整。
[说明]
下面C程序"的相关试题:
[填空题]
阅读以下说明和C程序代码,将程序补充完整。
[说明]
下面C程序代码的功能是:对于输入的一个正整数n(100≤n<1000),先判断其是否是回文数(正读反读都一样的数)。若不是,则将n与其反序数相加,再判断得到的和数是否为回文数,若还不是,再将该和数与其反序数相加并进行判断,依此类推,直到得到一个回文数为止。例如,278不是回文数,其反序数为872,相加后得到的1150还不是回文数,再将1150与其反序数511相加,得到的1661是回文数。
函数int isPalm(long
m)的功能是:将正整数m的各位数字取出存入数组中,然后判断其是否为回文数。若m是回文数则返回1,否则返回0。
[C程序代码]
#include<stdio.h>
#include<stdlib.h>
int isPalm(long m)
{
int i=0, k=0;
char str[32];
while(m>0) {
str[k++]= (1) +’0’;
m=m/10;
}
for(i=0; i<k/2;
i++)
if(str[i]!=str[ (2) ])return 0;
return 1;
}
int main(
)
{
long n, a, t;
printf("input a positive integer: "); scanf("%ld", &n);
if(n<100||n>=1000)return -1;
while( (3)
) {
printf("%id->", n);
for(a=0, t=n;
t>0; ){
a= (4) *10+t%10; t=t/10;
n= (5) ;
printf("%id/n", n);
system("pause"); return 0;
[填空题]请阅读下列程序代码,然后将程序的执行结果补充完整。
程序代码:
public class throwsExcepfion{
static void Proc(int se1)
throws ArithmeticException,ArraylndexOutOfBoundsException {
System.out.println("in Situation"+se1);
if(se1==0){
System.out.println("no Exception caught");
return;
}else if(se1==1){
int iArray[]=new int[4];
iArray [1]=3;
}
}
public static void main(String args[])[
try{
Proc(0);
Proc(1);
} catch(ArraylndexOutOfBoundsException e) {
System.out.println("Catch"+e);
}finally{
System.out.println("in Proc finally");
}
}
}
执行结果:
In Situation( )
no ExcepbOn cauSht
【14】
in Proc findly
[填空题]请阅读下列程序代码,然后将程序的执行结果补充完整。
程序代码:
Public class throwsException
static voidProc(intsel)
throws ArtthmeticExcepdon,AITaylndexOut of BoundsException
System.out println("In SimatiOn"+Sel);
if(sel==0)
System.out.println("noExceptioncallght");
return;
elseif(sel==1)
intiArray[]=newint[4];
i Array[1]=3;
public static void main(Stringargs[])
tfy
Proc(0);
Proc(1);
catch(ArraylndexOutOfBoundsExceptione)
System.out.println("Catch"+e);
flnally
Systern.out.println("inProcfinally");
执行结果:
In Situattion 0
no Exceptioncaught
inProcfinally
[填空题]请阅读下列程序代码,然后将程序的执行结果补充完整。
程序代码:
public class throwsExcepfion
static void Proc(int se1)
throws ArithmeticException,ArraylndexOutOfBoundsException
System.out.println("in Situation"+se1);
if(se1==0)
System.out.println("no Exception caught");
return;
else if(se1==1)
int iArray[]=new int[4];
iArray [1]=3;
public static void main(String args[])[
try
Proc(0);
Proc(1);
catch(ArraylndexOutOfBoundsException e)
System.out.println("Catch"+e);
finally
System.out.println("in Proc finally");
执行结果:
In Situation( )
no ExcepbOn cauSht
【14】
in Proc findly
[填空题]请阅读下列程序代码,然后将程序的执行结果补充完整。
程序代码:
public class throwsException
static void Proc(int sel)
throws ArithmeticException,ArrayIndexOutOfBoundsException
System.out.println("In Situation"+sel);
if(sel==0)
System.out.println(’no Exception caught");
return;
else if(sel==1)
int iArray[]=new int[4];
iArray[1]=3;
public static void main(String args[])
try
Proc(0);
Proc(1);
catch(ArrayIndexOutOfBoundsException e)
System.out.println("Catch"+e);
finally
System.out.println("in Proc finally");
执行结果:
In Situation 0
no Exception caught
【14】
in Proc finally
[单项选择]请阅读下列程序代码,然后将程序的执行结果补充完整。横线处应填写的内容是______。
程序代码:
public class throwsException
static void Proe(intsel)
throws Arithmetic Exception, Array Index Out OfBounds Exception
System. out. println("InSituation"+sel);
if(sel==0)
System. out. println( "noExeeption caught")
return;
else if(sel==1)
int iArray[]=newint[4];
iArray[1]=3;
public static void main(String args[])
try
Proc(0);
Proc(1);
catch(Array Index Out Of Bounds Exception e)
System. out. println( "Catch"+e);
finally
System. out. println("inProcfinally");
执行结果:
In Situation 0
no Exception caught
______
in Proc finally
A. In Situation 1
B. In Situation
C. with Catch
D. int iArray 1
[简答题][说明]
以下程序实现了在applet里移动图形文件,仔细阅读代码和相关注释,将程序补充完整。
[代码6-1]
import j ava. awt. *;
import j ava.awt.event.*;
import java.applet. Applet;
public class AppCIU extends Applet implements MouseMotionListener, MouseListener
{
Image IMG onClick=over(this) title=放大; // 声明 Image 类类型的变量 IMG onClick=over(this) title=放大
int x=70,y=60,posX=70,posY=60,dx,dy;
public void init ( )
{
IMG onClick=over(this) title=放大=getImage ( getCodeBase ( ) ,"mouse.gif" ); //载入影像
addMouseListener ( this );
addMouseMotionListener ( this );
}
public void mousePressed ( MouseEvent e )
{
dx=e.getX( )-posX; //取得按下之点与基准点X方向的距离
dy=e.getY( )-posY; //取得按下之点与基准点Y方向的距离
}
public void mouseDragged ( MouseEvent e )
{
(1)
(2)
if ( dx>0 && dx<120 && dy>0 && dy<60 ) //如果指针落在图形上方
{
Graphics g=getGraphics ( );
(3)
}
}
public void paint ( Graphics g )
{
(4)
(5