操做 | 描述 |
---|---|
push | 添加一個元素到棧的頂部 |
pop | 從棧的頂部移出一個元素 |
peek | 查看棧頂部的元素 |
isempty | 肯定棧是否爲空 |
size | 肯定棧的元素數目 |
public interface Stack<T> { public void push (T element); public T pop(); public T peek(); public boolean isEmpty(); public int size(); public String toString(); }
stack = (T[])(new Object[initialCapiry])
PP3.9的代碼無法上傳到馬雲,在這裏貼出來html
import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.text.method.ScrollingMovementMethod; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; import java.util.Stack; public class MainActivity extends AppCompatActivity { Stack<String> stack = new Stack(); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Button button1 = (Button)findViewById(R.id.button1); button1.setOnClickListener(new myButtonOnClickListener1()); Button button2 = (Button)findViewById(R.id.button2); button2.setOnClickListener(new myButtonOnClickListener2()); } public class myButtonOnClickListener1 implements View.OnClickListener{ public void onClick(View view){ EditText editText1 = (EditText)findViewById(R.id.editText1); stack.push(editText1.getText().toString()); EditText editText2 = (EditText)findViewById(R.id.editText2); editText2.setMovementMethod(ScrollingMovementMethod.getInstance()); editText2.setText(editText2.getText(),TextView.BufferType.EDITABLE); editText2.setText(stack.toString(), TextView.BufferType.EDITABLE ); System.out.println(editText2.getText().toString()); } } public class myButtonOnClickListener2 implements View.OnClickListener{ public void onClick(View view){ EditText editText1 = (EditText)findViewById(R.id.editText1); stack.pop(); EditText editText2 = (EditText)findViewById(R.id.editText2); editText2.setMovementMethod(ScrollingMovementMethod.getInstance()); editText2.setSelection(editText2.getText().length(),editText2.getText().length()); editText2.setText(stack.toString(),TextView.BufferType.EDITABLE); System.out.println(editText2.getText().toString()); } }
解析:==c(常量)<㏒₂n < n < n㏒₂n < n²< n³ < 2ⁿ < 3ⁿ< n!==很明顯,這道題若是把B看成n^2就會選B了。java
解析:㏒₂n < n,作題的時候沒有記熟,想固然的選了Candroid
代碼行數(新增/累積) | 博客量(新增/累積) | 學習時間(新增/累積) | ||
---|---|---|---|---|
目標 | 5000行 | 30篇 | 400小時 | |
第一週 | 0/0 | 1/1 | 8/8 | |
第二週 | 671/671 | 1/2 | 17/25 |