2008年10月31日 星期五
Homework 10-24-2008
1. Write a program to generate the series 1, 1, 2, 3, 5, 8, 13, ...The series has a property that the third number is the sum of the first and second numbers. For example, 2=1+1, 3=1+2, and 5=2+3.
2008年10月24日 星期五
2008年10月3日 星期五
反轉
Write a program that can reverse the order of an input string.
For example, if you input "ab", it will output "ba". If you input "abcdefg",
it should return "gfedcba".
String Processing
Write a program that starts with a line of text and then outputs that line of text with the first occurrence of "hate" changed to "love".
For example, a possible sample output might be The line of text to be changed is:I hate you.I have rephrased that line to read:I love you.Hint: You may consider use the methods: indexOf(A_String) and substring(Start, End) in your program.
For example, a possible sample output might be The line of text to be changed is:I hate you.I have rephrased that line to read:I love you.Hint: You may consider use the methods: indexOf(A_String) and substring(Start, End) in your program.
訂閱:
文章 (Atom)