问题 选择题
已知定义域为R的函数y=f(x)满足f(x+1)f(x-1)=1,且f(3)=3,则f(2009)=(  )
A.3B.
1
3
C.2009D.
1
2009
答案

由题意知,对于任意的实数都有f(x+1)f(x-1)=1,

令x=2代入上式得,f(3)f(1)=1,

∵f(3)=3,∴f(1)=

1
3

令x=x+1代入得,f(x+2)f(x)=1,则f(x+2)=

1
f(x)

f(x+4)=

1
f(x+2)
=f(x),∴f(x)是周期函数且周期是4,

∴f(2009)=f(4×502+1)=f(1)=

1
3

故选B.

单项选择题
填空题


请完善程序(程序文件名:Java_1.java)并进行调试。请在下画线处填入正确内容,然后删除下画线。请勿删除注释行和其他已有的语句内容。
[题目要求]
请完善程序并进行调试,使程序输出结果如下图所示。

源程序:
import javax.swing.JOptionPane;
public class Java_1 {
 public static void main(String args[]) {
  String s1,s2,s3,s4,output;
  s1=new String("hello");
  s2=new String("good bye");
  s3=new String("Happy Birthday");
  s4=new String("happy birthday");
  output="s1="+s1+"ins2="+s2+"ins3="+s3+"ins4="+s4+"\n\n"
  //测试字符串相等
  if(s1.equals("hello"))output=output+" (1) ";
  else output=output+"s1 does not equal\"hello\"\n":
  //用==测试相等
  if(s1=="hello")output+="s1 equals\"hello\"in":
  else output+="s1 does not equal\"hello\"\n":
  //忽略字符格式测试相等
  if(s3.equalsIgnoreCase(s4))output+="s3 equals s4\n":
  else output+="s3 does not equal s4\n":
  //内容比较
  output+="\ns1.compareTo(s2)is"+s1.compareTo(s2)+"\ns2.compareTo(s1)is"
    +s2.compareTo(s1)+"\ns1.compareTo(s1)is"+s1.compareTo(s1)
    +"\ns3.compareTo(s4)is"+s3.compareTo(s4)+"\ns4.compareTo(s3)is"
    +s4.compareTo(s3)+”\n\n“;
  //80试包含字符格式的域匹配
  if(s3.regionMatehes(0,s4,0,5))output+="First 5 characters of s3 and s4 match\n":
  else output+="First 5 characters of s3 and s4 do not match\n":
  //忽略字符格式的域匹配
  if(s3.regionMatches(true,0,s4,0,5))output+="First 5 characters of s3 and s4 match":
  else output+="First 5 characters of s3 and s4 do not match":
  JOptionPane. (2) (null,output,
  "字符串构造方法示例",JOptionPane.INFORMATION_MESSAGE):
  System.exit(0);
  }
}