📣 黑五价提前开抢|VIP一年通行证5折,蓝莓、Offer多多同步特惠
12
返回列表 发新帖
楼主: hurricane_e
跳转到指定楼层
上一主题 下一主题
收起左侧

[CS61B_Spring 2015] Discussion1-Intro to Java

🔗
 楼主| hurricane_e 2015-6-16 08:20:33 | 只看该作者
全局:
pjh4168789 发表于 2015-6-16 04:58
楼主用的是甚么软件CODING的,看截图和老师上课的一样诶

sublime 是text editor~
回复

使用道具 举报

🔗
西风吹草 2015-6-17 00:02:19 | 只看该作者
全局:
2. Mystery
What does mystery return if inputArray is the array 3, 0, 1, 6, 3, and k is 2?
2
Describe, in English, what mystery returns.
Mystery returns the index of the smallest number from inputArray[k] to the end of inputArray.
Extra for experts: What does mystery2 do if inputArray is the array 3, 0, 1, 6, 3?
0 1 3 3 6
Describe, in English, what mystery2 does to the array.
Mystery2 rearranges the inputArray ascendingly.

3. Writing Your First Program
public class fib {
        public static int fibo(int N){
                if (N <= 1){
                        return N;
                }else{
                        return fibo(N - 1) + fibo(N - 2);
                }
        }
       
        public static void main(String[] args){
                System.out.println(fibo(6));
        }

The returned value is 8.
回复

使用道具 举报

🔗
geminiiiiiii 2015-6-18 15:32:14 | 只看该作者
全局:
1 int size = 27; //declare an integer size,ssign it size with 27
2 String name = "Fido"; //declare a string name,assign it with Fido
3 Dog myDog = new Dog(name, size); //decalare a Dog object named myDog with instant variable name and size
4 int x = size - 5; //declare an integer x, assign x with size-5
5 if (x < 15) {
6 myDog.bark(8);
7 }//if x is less than 15,then invoke myDog's method bark() with argument 8
8
9 while (x > 3) {
10 myDog.play();
11 }//while x is greater than 3, then invoke myDog's method play()
12
13 int[] numList = {2, 4, 6, 8};//declare an integer array numList with 2,4,6,8
14 System.out.print("Hello ");//print 'Hello'
15 System.out.println("Dog: " + name); //print 'Dog:'+ name(Fido)
16
17 System.out.println(numList[1]); //print the integer in numList with index 1
18 if (numList[3] == 8) {
19 System.out.println("potato");
20 }//if numlist[3] equals 8, then print potato



2  
returns 2
return the smallest value's index after kth value
sorting the array in ascending order


3.
public static int fib(int N)
    if (N < 2){ return N;}
    return fib(N-1)+fib(N-2)
回复

使用道具 举报

🔗
HNAKXR 2016-1-28 15:38:04 | 只看该作者
全局:
2 Mystery
2
Find the index of the minimum from the k-th element to the end.
Change it to 0,1,3,3,6. Sort in ascending order.

3 Writing Your First Program
  1. public static int fib (int N) {
  2.         if (N == 0) { return 0;}
  3.         if (N == 1 || N == 2) { return 1;}
  4.         return fib(N) + fib(N-1);
  5. }
复制代码

评分

参与人数 1大米 +20 收起 理由
zzwcsong + 20

查看全部评分

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册账号
隐私提醒:
  • ☑ 禁止发布广告,拉群,贴个人联系方式:找人请去🔗同学同事飞友,拉群请去🔗拉群结伴,广告请去🔗跳蚤市场,和 🔗租房广告|找室友
  • ☑ 论坛内容在发帖 30 分钟内可以编辑,过后则不能删帖。为防止被骚扰甚至人肉,不要公开留微信等联系方式,如有需求请以论坛私信方式发送。
  • ☑ 干货版块可免费使用 🔗超级匿名:面经(美国面经、中国面经、数科面经、PM面经),抖包袱(美国、中国)和录取汇报、定位选校版
  • ☑ 查阅全站 🔗各种匿名方法

本版积分规则

>
快速回复 返回顶部 返回列表