欧美大屁股bbbbxxxx,狼人大香伊蕉国产www亚洲,男ji大巴进入女人的视频小说,男人把ji大巴放进女人免费视频,免费情侣作爱视频

    <small id='1118k3y2'></small><noframes id='es1zcuza'>

    <legend id='h5ndcave'><style id='9py8idfm'><dir id='ryx53yo1'><q id='n5hpkxqu'></q></dir></style></legend>
  • <tfoot id='bu0l8gnc'></tfoot>
      <bdo id='3853p0mj'></bdo><ul id='hxpcads9'></ul>
    <i id='5loj13v2'><tr id='skg1rp36'><dt id='m79gvu6s'><q id='eof054bp'><span id='c1nlzygz'><b id='w32l0b9r'><form id='667nco8y'><ins id='l6nofdbo'></ins><ul id='pe3qp5l8'></ul><sub id='ji5opqzb'></sub></form><legend id='uyzjmf58'></legend><bdo id='b7ahkvxt'><pre id='9ls1eab8'><center id='b0gg3gts'></center></pre></bdo></b><th id='51e38lzo'></th></span></q></dt></tr></i><div class="c8jzdxauzz" id='z6l9uivp'><tfoot id='dl6k1ffg'></tfoot><dl id='ka64gm0j'><fieldset id='yybahkfo'></fieldset></dl></div>

        歡迎來到入門教程網(wǎng)!

        Java編程

        當(dāng)前位置:主頁 > 軟件編程 > Java編程 >

        線性表java代碼 線性表基本操作代碼

        來源:本站原創(chuàng)|時間:2023-04-04|欄目:Java編程|點(diǎn)擊: 次

        java關(guān)于線性表的編程

        package?Test;

        import?java.io.BufferedReader;

        import?java.io.File;

        import?java.io.FileInputStream;

        import?java.io.FileNotFoundException;

        import?java.io.FileReader;

        import?java.io.IOException;

        import?java.io.InputStream;

        import?java.io.InputStreamReader;

        import?java.io.Reader;

        import?java.io.StringBufferInputStream;

        import?java.io.StringReader;

        import?java.util.Scanner;

        class?Test?{

        private?static?Node?firstList,?secondList,?resultList;

        private?static?void?input(Node?head)?throws?Exception?{

        int?a;

        int?b;

        int?i;

        Node?p?=?head;

        BufferedReader?reader?=?new?BufferedReader(new?InputStreamReader(

        System.in));

        //?讀取一行信息

        String?input?=?reader.readLine();

        //?以空格為分隔符,轉(zhuǎn)換成數(shù)組

        String[]?numbers?=?input.split("?");

        for(i=0;inumbers.length;){

        a?=?Integer.parseInt(numbers[i]);

        b?=?Integer.parseInt(numbers[i+1]);

        p.next?=?new?Node(a,?b);

        p?=?p.next;

        i+=2;

        }

        }

        public?static?void?main(String[]?args)?throws?Exception?{

        firstList?=?new?Node();

        secondList?=?new?Node();

        resultList?=?new?Node();

        Node?p=resultList;

        System.out.println("輸入第一個多項(xiàng)式");

        input(firstList);

        System.out.println("輸入第二個不等式");

        input(secondList);

        while(firstList.next!=nullsecondList.next!=null){

        if(firstList.next.zssecondList.next.zs){

        p.next=new?Node(firstList.next.xs,firstList.next.zs);

        p=p.next;

        firstList=firstList.next;

        }else?if(firstList.next.zssecondList.next.zs){

        p.next=new?Node(secondList.next.xs,secondList.next.zs);

        p=p.next;

        secondList=secondList.next;

        }else{

        p.next=new?Node(firstList.next.xs+secondList.next.xs,firstList.next.zs);

        p=p.next;

        firstList=firstList.next;

        secondList=secondList.next;

        }

        }

        if(firstList!=null){

        p.next=firstList.next;

        }

        if(secondList!=null){

        p.next=secondList.next;

        }

        p=resultList;

        while(p.next!=null){

        System.out.print(p.next.xs+"x^"+p.next.zs+"+");

        p=p.next;

        }

        System.out.println();

        }

        }

        public?class?Node?{

        public?int?xs;//系數(shù)

        public?int?zs;//指數(shù)

        public?Node?next=null;//指向下一個

        public?Node(int?a,int?b)?{

        xs=a;

        zs=b;

        }

        public?Node(){

        }

        }

        答案

        輸入第一個多項(xiàng)式

        5 4 3 2 1 1

        輸入第二個不等式

        4 4 3 2 1 1

        9x^4+6x^2+2x^1

        JAVA如何添加判斷線性表為0否則輸出線性表長度

        package?ba;

        //線性表抽象數(shù)據(jù)類型的java接口定義

        interface?List

        {

        ?public?boolean?isEmpty();?????????//接口方法1:判斷線性表是否為空

        ?public?void?insert(int?i?,int?element)?throws?Exception;?//接口方法2:在線性表的指定位置插入數(shù)據(jù)元素

        ?public?int?remove(int?i)??throws?Exception;?????//接口方法3:刪除線性表中指定位置的數(shù)據(jù)元素

        ?public?int?getData(int?i)?throws?Exception;?????//接口方法4:獲取線性表中指定位置的數(shù)據(jù)元素

        ?public?int?length();??????????//接口方法5:獲取線性表的長度(數(shù)據(jù)元素的個數(shù))

        }

        //順序表類SeqList,實(shí)現(xiàn)線性表接口

        class?SeqList??implements?List?

        {

        ?//在實(shí)現(xiàn)接口的類中定義成員變量

        ?private?int[]?listArray;??????//定義數(shù)組:listArray,用于保存線性表中的數(shù)據(jù)元素

        ?final?int?defaultSize=10;??????//定義常量:defaultSize,用于指定線性表的默認(rèn)長度

        ?private?int?size;?????????//定義變量:size,用于描述線性表中的數(shù)據(jù)元素的個數(shù)(線性表的長度)

        ?private?int?maxSize;???????//定義變量:maxSize,用于描述線性表中最大數(shù)據(jù)元素的個數(shù)(線性表的最大長度)

        ??

        ?//在實(shí)現(xiàn)接口的類中定義成員方法

        ?//構(gòu)造方法

        ?//定義函數(shù):initiate()

        ?public?void?initiate(int?sz)

        ?{

        ??maxSize=sz;???????????

        ??size=0;

        ??listArray=new??int[sz];??//創(chuàng)建一個整型數(shù)組?。?!

        ?}

        ?public?SeqList()?????//不帶參數(shù)的構(gòu)造方法

        ?{

        ??initiate(defaultSize);

        ?}

        ?public?SeqList(int?capacity)??//帶一個參數(shù)的構(gòu)造方法

        ?{

        ??initiate(capacity);

        ?}

        ?

        ?//成員方法:清空線性表

        ?public?void?clear()

        ?{

        ??this.size=0;

        ?}

        ?

        ?//實(shí)現(xiàn)?接口中定義的方法

        ?

        ?public?boolean?isEmpty()?????????//接口方法1:判斷線性表是否為空

        ?{

        ??return?this.size==0;?//說明:==:是邏輯判斷是否相等,如果相等返回值布爾值:真?true(1),否則返回假?false?0

        ?}

        ?

        ?public?void?insert(int?index?,int?element)?throws?Exception?//接口方法2:在線性表的指定位置插入數(shù)據(jù)元素

        ???????????//加載異常事務(wù)處理方法????

        ?{?????

        ??if(size==maxSize)

        ??{

        ???throw?new?Exception("順序表已滿,無法插入!");?//如果程序中需要將存在的異常事件拋出,則必須事先加載異常處理的方法

        ???//拋出異常

        ??}

        ??if(index0?||?indexsize)

        ??{

        ???throw?new?Exception("參數(shù)錯誤!");

        ??}

        ??for(int?j=size;jindex;j--)

        ??{

        ???listArray[j]=listArray[j-1];

        ??}

        ??listArray[index]=element;

        ??size++;?

        ?}

        ?

        ?public?int?remove(int?i)??throws?Exception?????//接口方法3:刪除線性表中指定位置的數(shù)據(jù)元素

        ?{

        ??if(size==0)

        ??{

        ???throw?new?Exception("順序表已空,無法刪除!");

        ??}

        ??if(i0?||?isize-1)

        ??{

        ???throw?new?Exception("參數(shù)錯誤!");

        ??}

        ??int?it?=listArray[i];

        ??for(int?j=i;jsize-1;j++)

        ??{

        ???listArray[j]=listArray[j+1];

        ??}

        ??size--;

        ??return?it;??//將刪除數(shù)據(jù)元素后新的數(shù)組??

        ?}

        ?//獲取線性表中指定位置的數(shù)據(jù)元素

        ?public?int?getData(int?i)?throws?Exception?????//接口方法4:獲取線性表中指定位置的數(shù)據(jù)元素

        ?{

        ??return?listArray[i];

        ?}

        ?//求線性表的長度

        ?public?int?length()??????????//接口方法5:獲取線性表的長度(數(shù)據(jù)元素的個數(shù))

        ?{

        ??return?size;

        ?}

        }

        public?class?test?{???????//定義public類:(1)在創(chuàng)建項(xiàng)目時指定的類

        ?public?static?void?main(String?args[])??????//(2)main方法應(yīng)當(dāng)在public類中

        ?{

        ??SeqList?seqList?=?new?SeqList(100);

        ??//定義類的對象。在定義類的對象時,通過調(diào)用構(gòu)造方法對類的成員變量進(jìn)行賦值

        ??//如果一個類中存在多個構(gòu)造方法時,稱為構(gòu)造方法重載。

        ??//調(diào)用構(gòu)造方法時,由系統(tǒng)根據(jù)所調(diào)用的構(gòu)造方法的參數(shù)個數(shù)和數(shù)據(jù)類型自動調(diào)用與之相匹配的構(gòu)造方法

        ??int?n=10;

        ??try???????//try語句中的內(nèi)容是指:需要對程序運(yùn)行的異常事件進(jìn)行捕獲

        ??{

        ???for(int?i=0;i=n;i++)

        ???{

        ????seqList.insert(i,(i+1));?//通過類的對象調(diào)用類的成員方法

        ???}

        ???seqList.remove(4);

        ???for(int?i=0;in;i++)

        ???{

        ????System.out.println(seqList.getData(i)+"?");

        ???}

        ???//請?jiān)诖颂砑优袛嗑€性表是否為空,如果為空,則提示用戶線性表為空,否則輸出線性表的長度

        ???

        ??}

        ??

        ??catch(Exception?e)???//catch語句的作用是:將try語句中捕獲的異常內(nèi)容拋出

        ??{

        ???System.out.println(e.getMessage());

        ??}

        ??

        ?}

        }

        如何在這程序中添加

        java建立一個線性表

        import java.util.ArrayList;

        import java.util.List;

        public class ListDemo {

        public static void main(String[] args) {

        int numLength = 10;

        int deleteNum = 5;

        ListInteger list = new ArrayListInteger();

        init(numLength,list);

        delete(deleteNum,list);

        print(list);

        }

        private static void print(ListInteger list) {

        for(int i=0;ilist.size();i++){

        System.out.print(list.get(i) +"\t");

        }

        }

        private static void delete(int deleteNum,ListInteger list) {

        for (int i=0;ilist.size();i++){

        if((int)list.get(i)==deleteNum){

        list.remove(i);

        }

        }

        }

        private static void init(int numLength,ListInteger list) {

        for(int i=1;i=numLength;i++){

        list.add(i);

        }

        }

        }

        //當(dāng)然你要是把你的代碼貼上來就更好了,可以幫忙找出問題,另外也可以知道你對java了解到哪個程度了呵,給出的幫助可能更實(shí)際一些

          <small id='9upcntcq'></small><noframes id='5dfisqht'>

          <legend id='s51ehvmv'><style id='tp2xbl5g'><dir id='gdm8tzzm'><q id='2ze84fut'></q></dir></style></legend>
          <tfoot id='pag0ort5'></tfoot>
              <tbody id='mnmp2cqi'></tbody>
            <i id='825q61tt'><tr id='ojwqid5o'><dt id='zkp9bmkj'><q id='udb4d7za'><span id='ijba2jlh'><b id='9midmkex'><form id='63tmhdvc'><ins id='kkrl1mc3'></ins><ul id='botz7j1b'></ul><sub id='8difb2bs'></sub></form><legend id='hrvv60ib'></legend><bdo id='ntt4odzf'><pre id='9n455ix2'><center id='ovyze2l2'></center></pre></bdo></b><th id='dyu4ardt'></th></span></q></dt></tr></i><div class="c8jzdxauzz" id='9dvv93n8'><tfoot id='m4obpgby'></tfoot><dl id='xmub8ozq'><fieldset id='nameo4uh'></fieldset></dl></div>

                • <bdo id='ucpp9o4j'></bdo><ul id='5xw8gf0n'></ul>

                  上一篇:包含Java11查看源代碼的詞條

                  欄    目:Java編程

                  下一篇:沒有了

                  本文標(biāo)題:線性表java代碼 線性表基本操作代碼

                  本文地址:http://mengdiqiu.com.cn/a1/Javabiancheng/17244.html

                  網(wǎng)頁制作CMS教程網(wǎng)絡(luò)編程軟件編程腳本語言數(shù)據(jù)庫服務(wù)器

                  如果侵犯了您的權(quán)利,請與我們聯(lián)系,我們將在24小時內(nèi)進(jìn)行處理、任何非本站因素導(dǎo)致的法律后果,本站均不負(fù)任何責(zé)任。

                  聯(lián)系QQ:835971066 | 郵箱:835971066#qq.com(#換成@)

                  Copyright © 2002-2020 腳本教程網(wǎng) 版權(quán)所有

                    <legend id='xam1enxp'><style id='qyraa07v'><dir id='tmgvd409'><q id='whyill74'></q></dir></style></legend>

                    <small id='ypvo2zab'></small><noframes id='bpd8yba6'>

                        <bdo id='yi29qanp'></bdo><ul id='ohf7yumt'></ul>
                      <tfoot id='dqzcovd3'></tfoot>
                    1. <i id='yu0pbf75'><tr id='o5f8s0pd'><dt id='ugz5zwoa'><q id='rx5j4d10'><span id='49cgjjh8'><b id='g6g1e8pb'><form id='j5di7xys'><ins id='pao05kv7'></ins><ul id='os3a6z24'></ul><sub id='5wx65llr'></sub></form><legend id='3s2dz85b'></legend><bdo id='sxf7669e'><pre id='l88ngeyf'><center id='cutshkne'></center></pre></bdo></b><th id='0od093tt'></th></span></q></dt></tr></i><div class="c8jzdxauzz" id='5emjh3pt'><tfoot id='qpafd50z'></tfoot><dl id='65omyecm'><fieldset id='0ydsv6r1'></fieldset></dl></div>