Ai
1 Star 0 Fork 0

冷冲/git

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
SecondActivity.java 2.71 KB
一键复制 编辑 原始数据 按行查看 历史
冷冲 提交于 2019-10-27 13:23 +08:00 . 实验4,5
package com.example.sy64;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Environment;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.util.StringTokenizer;
public class SecondActivity extends Activity implements View.OnClickListener {
private LinearList linearList=new LinearList();
@Override
protected void onCreate(Bundle savedinstance) {
super.onCreate(savedinstance);
setContentView(R.layout.activity_second);
Intent a=getIntent();
String str=a.getStringExtra("h");
try {
Linear(str);
} catch (IOException e) {
e.printStackTrace();
}
}
public void Linear(String str) throws IOException {
StringTokenizer str1=new StringTokenizer(str);
while(str1.hasMoreTokens()){
linearList.Add(new LinearNode(Integer.valueOf(str1.nextToken())));
}
String result="当前链表元素个数为:\n"+linearList.getnLengChong()+"\n元素:"+linearList.toString()+"\n";
InputStream inputStream=getAssets().open("test.txt");
int size=inputStream.available();
byte[] a=new byte[size];
inputStream.read(a);
inputStream.close();
String content=new String(a);
StringTokenizer stringTokenizer=new StringTokenizer(content);
int x1=Integer.valueOf(stringTokenizer.nextToken());
int x2=Integer.valueOf(stringTokenizer.nextToken());
linearList.AddJ(linearList.Count(4).getElement(),x1);
linearList.AddH(x2);
String result1="加入数1数2,当前链表元素个数为:\n"+linearList.getnLengChong()+"\n元素:"+linearList.toString()+"\n";
linearList.SubJ(x1);
String result2="删去数1,当前链表元素个数为:\n"+linearList.getnLengChong()+"\n元素:"+linearList.toString()+"\n";
TextView text=(TextView)findViewById(R.id.j);
TextView text1=(TextView)findViewById(R.id.k);
TextView text2=(TextView)findViewById(R.id.b);
text.setText(result);
text1.setText(result1);
text2.setText(result2);
}
@Override
public void onClick(View v) {
TextView a = (TextView) findViewById(R.id.sort);
String str=linearList.Sort();
str+="排序后的链表元素为:\n" + linearList.toString();
a.setText(str);
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/cold_impact/git.git
git@gitee.com:cold_impact/git.git
cold_impact
git
git
master

搜索帮助