版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
word
word
/
word
1¡¢¶¨ÒåÒ»¸öStudentÀ࣬ӵÓкÍÍи£³É¼¨ÊôÐÔ£¬±àдһ¸ö³ÌÐò£¬Íê³ÉÒÔϲÙ×÷£º
£¨1£©°ÑÏÂÁÐѧÉú¶ÔÏó´æ·ÅÔÚÒ»¸öÁ´±íÖУ¬ºÍÍи£³É¼¨ÈçÏÂËùʾ£º
£º¡°Ð¡Ã÷¡±£¬¡°Ö¾Ç¿¡±£¬¡°ÔÆ»·¡±£¬¡°Ö¾»ª¡±£¬¡°ÌƵ¿¡±£¬¡°¶ÅÌ족£¬¡°Óí¡±
Íи£³É¼¨£º86£¬91£¬72£¬86£¬84£¬82£¬86
£¨2£©ÊäÈëÒ»¸öеÄѧÉú¶ÔÏ󣬰üº¬ºÍÍи£³É¼¨£¬½«ÐÂѧÉúµÄÍи£³É¼¨ÓëÁ´±í¶ÔÏó½øÐжԱȣ¬È»ºóÊä³öÏàͬÍи£³É¼¨µÄѧÉú£¬¾ßÌåÏÔʾ½á¹ûÈçÏÂËùʾ£º
ÐÂѧÉú¡ª¡ªÍõÁÕµÄÍи£³É¼¨(86)ÓëÏÂÁÐѧÉú£º
СÃ÷(86)
Ö¾»ª(86)
Óí(86)
µÄÍи£³É¼¨Ïàͬ
¡¾·ÖÊý¡¿15·Ö
importjava.util.Iterator;
importjava.util.LinkedList;
publicclassT1{
publicstaticvoidmain(String[]args){
LinkedList<Student>list=newLinkedList<Student>();
list.add(newStudent("СÃ÷",86));
list.add(newStudent("־ǿ",91));
list.add(newStudent("ÔÆ»·",72));
list.add(newStudent("Ö¾»ª",86));
list.add(newStudent("ÌƵ¿",84));
list.add(newStudent("¶ÅÌì",82));
list.add(newStudent("Êô",86));
Studentstudent=newStudent("ÍõÁÕ",86);
Iterator<Student>it=list.iterator();
System.out.println("ÐÂѧÉú¡ª¡ª"++"µÄÍи£³É¼¨("+student.score+")ÓëÏÂÁÐѧÉú");
while(it.hasNext()){
Studentstu=it.next();
if(stu.score==student.score){
System.out.println(+"("+stu.score+")");
}
}
System.out.println("µÄÍи£³É¼¨Ïàͬ");
}
}
classStudent{
Stringname;//ѧÉú
intscore;//ѧÉúÍи£³É¼¨
publicStudent(Stringname,intscore){
=name;
this.score=score;
}
}
2¡¢Ê¹ÓÃJavaµÄÓ¦Óñà³Ì½Ó¿Ú£¬±àдһ¸ö³ÌÐò£¬ÊµÏÖÏÔʾµ±Ç°ÈÕÆÚºÍʱ¼ä£¬²¢ÏÔʾµ±ÔÂÈÕÀúµÄЧ¹û¡£ÔÚÈÕÀúÏÔʾÖУ¬µ±Ç°ÈÕÆÚºó¼Ó¡°*¡±Í»³ö£¬¾ßÌåÏÔʾ½á¹ûÈçÏÂͼËùʾ£º
¡¾·ÖÊý¡¿15·Ö
3¡¢¼ÙÉèÓÐÒ»Êý×飬°üº¬12¸öÕûÊý£¬ÒѾ°´ÉýÐòÅźá£Çë±àдһ¸ö³ÌÐò£¬Ê¹ÆäÄÜ´ÓÖ¸¶¨Î»ÖÿªÊ¼µÄn£¨0<n<12£©¸öÊý°´ÄæÐòÖØÐÂÅÅÁв¢Êä³öеÄÍêÕûÊý×é¡£
ÀýÈ磺ÔÊý×éΪ5,9,11,15,16,19,21,32,45,48,72,83£¬ÒªÇó°Ñ´ÓµÚ5¸öÊý¿ªÊ¼µÄ4¸öÊý°´Äæ
ÐòÖØÐÂÅÅÁУ¬ÔòµÃµ½µÄÐÂÊý×éΪ5,9,11,15,32,21,19,16,?45,48,72,83¡£
¡¾·ÖÊý¡¿15·Ö
publicclassT3{
publicstaticvoidmain(String[]args){
int[]array=newint[]{5,9,11,15,16,19,21,32,45,48,72,83};
System.out.println("ÔÊý×éΪ");
for(inti=0;i<array.length;i++)
System.out.print(array[i]+"\t");
intstart=4;//Ö¸¶¨Î»ÖÃ
intn=5;//¶àÉÙ¸öÊý
for(inti=start-1;i<start+n-1;i++)
for(intj=i+1;j<start+n-1;j++){
if(array[i]<array[j]){
inttemp=array[i];
array[i]=array[j];
array[j]=temp;
}
}
System.out.println("\nµÃµ½ÐÂÊý×éΪ");
for(inti=0;i<array.length;i++)
System.out.print(array[i]+"\t");
}
}
4¡¢Ê¹ÓÃRandomAccessFileÁ÷£¬±à³Ìͳ¼ÆËù¸øËزÄÎļþ¡°NEWSPAPER.txt¡±ÖеÄÓ¢Îĵ¥´Ê³öÏֵļ¸ÖÖÇé¿ö£¬¾ßÌåÒªÇóÈçÏ£º
£¨1£©Í³¼Æ³öÏֵĵ¥´Ê¸öÊý£»
£¨2£©Í³¼Æ»¥²»ÏàͬµÄµ¥´ÊÊýÁ¿£»
£¨3£©Í³¼Æÿ¸öµ¥´Ê³öÏÖµÄƵÂÊ£¬²¢½«ÕâЩµ¥´Ê°´ÆµÂÊ´Ó´óµ½Ð¡µÄ˳ÐòÏÔʾÔÚÒ»¸öTextAreaÖУ¨ÆµÂÊÏàͬµÄµ¥´ÊÏÔʾ˳ÐòÎÞÒªÇ󣩡£
³ÌÐòÔËÐÐЧ¹ûÈçÏÂͼËùʾ£º
¡¾·ÖÊý¡¿15·Ö
importjava.awt.BorderLayout;
importjava.awt.event.ActionEvent;
importjava.awt.event.ActionListener;
importjava.io.File;
importjava.io.FileNotFoundException;
importjava.io.IOException;
importjava.io.RandomAccessFile;
importjava.util.ArrayList;
importjava.util.Collections;
importjava.util.parator;
importjava.util.HashMap;
importjava.util.Iterator;
importjava.util.List;
importjava.util.Map;
importjava.util.Set;
importjavax.swing.utton;
importjavax.swing.JFrame;
importjavax.swing.JTextArea;
publicclassT4extendsJFrameimplementsActionListener{
Filefile=newFile("NEWSPAPER.txt");
RandomAccessFileraf=null;
ArrayList<String>list=newArrayList<String>();
HashMap<String,Integer>map=newHashMap<String,Integer>();
Stringstr=null;//¶ÁÈ¡µÄÒ»ÐÐÎı¾
Stringstrs[]=null;//Ò»ÐÐÖе¥´ÊÊý×é
uttonopen=newutton("OpenFile");
JTextAreainfo=newJTextArea("");
publicT4(){
this.setSize(350,500);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setVisible(true);
open.addActionListener(this);
this.setLocationRelativeTo(null);
this.add(open,BorderLayout.NORTH);
this.add(info,BorderLayout.CENTER);
}
publicstaticvoidmain(String[]args){
newT4();
}
publicvoidactionPerformed(ActionEvente){
if(e.getSource()==open){
try{
raf=newRandomAccessFile(file,"rw");
while((str=raf.readLine())!=null){
strs=str.split("\\W|\\d");
for(inti=0;i<strs.length;i++){
if(strs[i].length()>0){
list.add(strs[i]);
if(map.containsKey(strs[i])){
intvalue=map.get(strs[i]);
map.put(strs[i],++value);
}else{
map.put(strs[i],1);
}
}
}
}
info.append(file.getPath()+"Îı¾Öй²ÓÐ"+list.size()+"¸öÓ¢Îĵ¥´Ê");
info.append("\nÆäÖÐÓÐ"+map.size()+"¸ö»¥²»ÏàͬµÄµ¥´Ê");
Set<Map.Entry<String,Integer>>set=map.entrySet();
Listlists=newArrayList(set);
Collections.sort(lists,
newparator<Map.Entry<String,Integer>>(){
publicintpare(Map.Entry<String,Integer>o1,
Map.Entry<String,Integer>o2){
//List
returno2.getValue()-o1.getValue();
}
});
Iterator<Map.Entry<String,Integer>>its=lists.iterator();
while(its.hasNext()){
Map.Entry<String,Integer>entry=its.next();
Stringkey=entry.getKey();
Integercount=entry.getValue();
info.append("\n"+key+":"+count+"/"+list.size()
+"="+(float)count/list.size());
}
}catch(FileNotFoundExceptionex){
ex.printStackTrace();
}catch(IOExceptionex){
ex.printStackTrace();
}
}
}
}
5¡¢ÓÃSocket±à³ÌʵÏÖ¿Í»§¶Ë¶ÁÈ¡·þÎñÆ÷¶Ë¶ÔÏóµÄ½»»¥¹ý³Ì£¬¼´¿Í»§¶Ë½«·þÎñÆ÷¶ËµÄÎı¾Çø£¨TextArea£©¶ÔÏó¶ÁÈ¡µ½¿Í»§¶Ë£¬²¢Ìí¼Óµ½´°¿ÚÖС£ÐèÒª±à³ÌʵÏÖ2¸ö³ÌÐòÎļþ£¬Ò»¸öÊÇ·þÎñÆ÷¶Ë³ÌÐòÎļþ£ºServer.java£¬ÁíÒ»¸öÊÇ¿Í»§¶Ë³ÌÐòÎļþ£ºClientA.java¡£·þÎñÆ÷¶Ë³ÌÐò±àÒëͨ¹ýºó£¬´´½¨Ò»¸öServerSocketÔڶ˿Ú4331¼àÌý¿Í»§ÇëÇ󣬵ȴý¿Í»§¶Ëºô½Ð£¬Ò»µ©½ÓÊÕµ½¿Í»§¶ËÇëÇó£¬ÔòÆô¶¯Ò»¸öÐÂỊ̈߳¬Êä³öÒ»¸öÎı¾Çø¶ÔÏó²¢·¢Ë͵½¿Í»§¶Ë£¬¿Í»§¶Ë½ÓÊÕ·þÎñÆ÷¶Ë´«¹ýÀ´µÄÎı¾Çø¶ÔÏ󣬲¢ÏÔʾÆäÈÝ¡£
¡¾·ÖÊý¡¿20·Ö
Client-->
importjava.awt.BorderLayout;
importjava.awt.TextArea;
importjava.io.IOException;
importjava.io.InputStream;
import.Socket;
importjavax.swing.JFrame;
publicclassClientAextendsJFrame{
TextAreainfo=newTextArea("");
publicClientA(){
this.setVisible(true);
this.setSize(350,300);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setVisible(true);
this.setLocationRelativeTo(null);
this.add(info,BorderLayout.CENTER);
client();
}
publicvoidclient(){
try{
Socketclient=newSocket("",4331);
InputStreamis=client.getInputStream();
byte[]data=newbyte[1024];
while((is.read(data))!=-1){
info.append(newString(data));
}
System.out.println("»ñÈ¡³É¹¦");
}catch(IOExceptione){
e.printStackTrace();
}
}
publicstaticvoidmain(String[]args){
newClientA();
}
}
Server-->
importjava.awt.BorderLayout;
importjava.awt.TextArea;
importjava.io.IOException;
importjava.io.OutputStream;
import.ServerSocket;
import.Socket;
importjavax.swing.JFrame;
publicclassServerextendsJFrame{
ServerSocketserver=null;
TextAreainfo=newTextArea("µÈ´ý¿Í»§¶ËµÄÇëÇó²¢°Ñ´ËÐÅÏ¢·¢Ë͸ø¶Ô·½");
publicServer(){
this.setVisible(true);
this.setSize(350,300);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setVisible(true);
this.setLocationRelativeTo(null);
this.add(info,BorderLayout.CENTER);
service();
}
publicvoidservice(){
try{
server=newServerSocket(4331);
while(true){
newSent(server,server.accept(),info.getText()).start();
System.out.println("³É¹¦Óë¿Í»§¶ËÁ¬½Ó");
}
}catch(IOExceptionex){
ex.printStackTrace();
}
}
publicstaticvoidmain(String[]args){
newServer();
}
}
classSentextendsThread{
ServerSocketsev;
Stringinfo;
Socketsocket;
publicSent(ServerSocketser,Socketsocket,Stringinfo){
this.sev=ser;
this.socket=socket;
=info;
}
publicvoidrun(){
try{
OutputStreamout=socket.getOutputStream();
out.write(info.getBytes());
}catch(IOExceptionex){
ex.printStackTrace();
}
}
}
6¡¢ÔÚAccess2003Öд´½¨Ò»¸öÐÂÊý¾Ý¿â£¬ÃûΪԱ¹¤¿â.mdb¡£ÅäÖÃODBCÇý¶¯Ô´£¬Á¬½Óµ½Ô±¹¤¿âÉÏ¡£±àд³ÌÐò£¬Ê¹ÓÃJDBC-ODBCÇÅÇý¶¯³ÌÐò£¬ÔÚAccessÊý¾Ý¿âÖд´½¨Ô±¹¤±í£¬²¢Í¨¹ý³ÌÐòÏò±íÖвåÈëÈçÏÂÊý¾Ý¡£±íµÄ½á¹¹ºÍʾÀýÊý¾ÝÈçÏÂËùʾ£º
Ô±¹¤±í£º
ʹÓÃJavaÓïÑÔ±àд³ÌÐò£¬ÔÚÔ±¹¤¿âÖд´½¨Ô±¹¤±í£¬²åÈëÉÏÊö3Ìõ¼Ç¼£¬È»ºó²éѯ±íÊý¾Ý²¢ÏÔʾ¡£¾ßÌåÒªÇóÈçÏ£º
£¨1£©Ê¹ÓÃJDBC-ODBCÇÅÇý¶¯³ÌÐò£»
£¨2£©Í¨¹ý³ÌÐò£¬ÔÚÔ±¹¤¿âÖд´½¨Ô±¹¤±í£¬±í½á¹¹ÈçÉÏËùʾ£»
£¨3£©Í¨¹ý³ÌÐò¶ÁÈ¡±í½á¹¹ÐÅÏ¢²¢ÏÔʾ£»
£¨4£©Ê¹ÓÃPreparedStatementÓï¾äÀ´²åÈë3Ìõ¼Ç¼£»
£¨5£©²éѯ³ö±íÖÐËùÓмǼ£¬²¢°´ÕÕÖ÷¼üÉýÐòÏÔʾ¡£
²Î¿¼Ìáʾ´úÂ룺
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver")
Connectionconn=DriverManager.getConnection("jdbc:odbc:employees","","")
¡¾·ÖÊý¡¿20·Ö
importjava.sql.Connection;
importjava.sql.DriverManager;
importjava.sql.PreparedStatement;
importjava.sql.ResultSet;
importjava.sql.SQLException;
importjava.sql.Statement;
publicclassT6{
publicstaticConnectionconn;
publicstaticvoidmain(String[]args)throwsClassNotFoundException,
SQLException{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conn=DriverManager.getConnection("jdbc:odbc:employees");
createTable();
Stringsql="insertintoemployeevalues(1001,'Jerry','jerry126.',3000,'1982-05-18')";
insert(sql);
sql="insertintoemployeevalues(1002,'Mike','Mike126.',3400,'1985-08-18')";
insert(sql);
sql="insertintoemployeevalues(1003,'John','John126.',3200,'1982-09-18')";
insert(sql);
sql="select*fromemployeeorderbyemloyee_idasc";
query(sql);
}
publicstaticvoidcre
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- CHT 1024-2011 影像控制测量成果质量检验技术规程
- 2022-2023年部编版七年级语文上册期末考试题及答案【真题】
- 人教版五年级上册语文期末测试卷【带答案】
- 2022版数学课程标准复习题(含答案)
- 人教版九年级数学下册期中考试卷(加答案)
- 2024届普通高等学校招生全国统一考试模拟(五)理综生物试题
- 2024届贵州省贵阳市一中高三一模生物试题(含答案解析)
- 2024年运载火箭跟踪、遥测及测控设备项目安全调研评估报告
- CrossMAb技术:推动双特异性及多特异性抗体治疗的创新与应用
- 2024年油气钻采设备项目创业投资方案
- 美国地板市场调研报告
- 2024年福建宁德市港务集团有限公司招聘笔试参考题库含答案解析
- 五金配件安装承揽合同
- 协同拯救多学科合作挽救危重病人
- 汽车自动变速器图解
- 数字化革命2024年全球数字经济趋势分析
- 低段英语绘本阅读教学设计
- 台州程扬电机配件有限公司年产300万套电机接线盒技术改造项目环境影响报告
- 轨道交通 机车车辆车载能量储存系统电源 混合串联系统 征求意见稿
- 机器人辅助康复治疗
- 2024年浙江温州市铁投集团招聘笔试参考题库含答案解析
评论
0/150
提交评论