亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

蟲蟲首頁| 資源下載| 資源專輯| 精品軟件
登錄| 注冊

Main

  • 學生管理系統

    運行: 需要連接數據庫,本人用的SQL2008R2,使用其更改版本導入就行 com.operate.MainMain.java 為主函數接口 PS:如果beautyeye_lnf.jar包報錯,導入其lib目錄下的對應包即可 登錄: 管理員-- 帳號;密碼 :admin;1  或者  1;1 學  生-- 帳號;密碼 :01001;01001 數據庫: com.means.sql 包 SqlKey.java 提供了參數 com.means.sql 包 SqlCmd.java  提供了當前數據庫的查詢語句(不推薦更改,數據庫已提供) 還需改進: 課程表數據跟學生成績數據太少, 課程表的管理沒有寫,偷個懶 如果需要可以對照 StuManage 跟 StuUpdate 倆個類來寫,直接復制就可以了。 PS: 還有問題可以聯系 Q.2095204800

    標簽: 管理系統

    上傳時間: 2017-06-27

    上傳用戶:aaass

  • TMS320VC5416-DSK-example

    A simple example of audio signal processing on TMS320VC5416 USB DSK board. Main source is contained in tone.c file, memory configuration - tonecfg.cmd. Folder docs/ contains useful docmentation on board, its components and libraries. The example's configuration is based on example "tone" from Code Composer Studio's 3.1 example for 5416 DSK.

    標簽: DSK-example 5416 TMS 320 VC

    上傳時間: 2017-09-29

    上傳用戶:wang1104014663

  • 12345

    /****************temic*********t5557***********************************/    #include   <at892051.h>     #include   <string.h>    #include   <intrins.h>     #include   <stdio.h>     #define    uchar    unsigned char     #define    uint     unsigned int     #define    ulong    unsigned long     //STC12C2051AD的SFR定義     sfr  WDT_CONTR = 0xe1;//stc2051的看門狗??????     /**********全局常量************/    //寫卡的命令     #define    write_command0       0//寫密碼     #define    write_command1       1//寫配置字     #define    write_command2       2//密碼寫數據     #define    write_command3       3//喚醒     #define    write_command4       4//停止命令     #define    TRUE       1     #define    FALSE      0     #define    OK         0     #define    ERROR      255     //讀卡的時間參數us     #define ts_min          250//270*11.0592/12=249//取近似的整數     #define ts_max          304//330*11.0592/12=304     #define t1_min          73//90*11.0592/12=83:-10調整     #define t1_max          156//180*11.0592/12=166     #define t2_min          184//210*11.0592/12=194     #define t2_max          267//300*11.0592/12=276     //***********不采用中斷處理:采用查詢的方法讀卡時關所有中斷****************/     sbit p_U2270B_Standby = P3^5;//p_U2270B_Standby PIN=13     sbit p_U2270B_CFE = P3^3;//p_U2270B_CFE     PIN=6     sbit p_U2270B_OutPut = P3^7;//p_U2270B_OutPut  PIN=2     sbit wtd_sck = P1^7;//SPI總線     sbit wtd_si = P1^3;    sbit wtd_so = P1^2;    sbit iic_data = P1^2;//lcd IIC     sbit iic_clk = P1^7;    sbit led_light = P1^6;//測試綠燈     sbit led_light1 = P1^5;//測試紅燈     sbit led_light_ok  = P1^1;//讀卡成功標志     sbit fengmingqi = P1^5;    /***********全局變量************************************/       uchar data Nkey_a[4] = {0xA0, 0xA1, 0xA2, 0xA3};//初始密碼             //uchar idata card_snr[4];   //配置字     uchar data bankdata[28] = {1,2,3,4,5,6,7,1,2,3,4,5,6,7,1,2,3,4,5,6,7,1,2,3,4,5,6,7};     //存儲卡上用戶數據(1-7)7*4=28     uchar data cominceptbuff[6] = {1,2,3,4,5,6};//串口接收數組ram     uchar command; //第一個命令     uchar command1;//     //uint  temp;     uchar j,i;    uchar myaddr = 8;    //uchar ywqz_count,time_count;             //ywqz jishu:     uchar bdata DATA;    sbit BIT0 = DATA^0;    sbit BIT1 = DATA^1;    sbit BIT2 = DATA^2;    sbit BIT3 = DATA^3;    sbit BIT4 = DATA^4;    sbit BIT5 = DATA^5;    sbit BIT6 = DATA^6;    sbit BIT7 = DATA^7;    uchar bdata DATA1;    sbit BIT10 = DATA1^0;    sbit BIT11 = DATA1^1;    sbit BIT12 = DATA1^2;    sbit BIT13 = DATA1^3;    sbit BIT14 = DATA1^4;    sbit BIT15 = DATA1^5;    sbit BIT16 = DATA1^6;    sbit BIT17 = DATA1^7;    bit i_CurrentLevel;//i_CurrentLevel  BIT 00H(Saves current level of OutPut pin of U2270B)     bit timer1_end;    bit read_ok = 0;    //緩存定時值,因用同一個定時器     union HLint { uint W;    struct   {    uchar H;uchar L;   }   B; };//union HLint idata a     union HLint data a;    //緩存定時值,因用同一個定時器     union HLint0 { uint W;    struct {   uchar H;   uchar L; } B; };//union HLint idata a     union HLint0 data b;    /**********************函數原型*****************/    //讀寫操作     void f_readcard(void);//全部讀出1~7 AOR喚醒     void f_writecard(uchar x);//根據命令寫不同的內容和操作     void f_clearpassword(void);//清除密碼     void f_changepassword(void);//修改密碼     //功能子函數     void write_password(uchar data *data p);//寫初始密碼或數據     void write_block(uchar x,uchar data *data p);//不能用通用指針     void write_bit(bit x);//寫位     /*子函數區*****************************************************/    void delay_2(uint x)    //延時,時間x*10us@12mhz,最小20us@12mhz     {    x--; x--;    while(x)    {      _nop_();      _nop_();      x--;    }    _nop_();//WDT_CONTR=0X3C;不能頻繁的復位     _nop_();    }    /////////////////////////////////////////////////////////////////////     void initial(void)    {    SCON = 0x50; //串口方式1,允許接收     //SCON  =0x50;     //01010000B:10位異步收發,波特率可變,SM2=0不用接收到有效停止位才RI=1,     //REN=1允許接收     TMOD = 0x21; //定時器1 定時方式2(8位),定時器0 定時方式1(16位)     TCON = 0x40; //設定時器1 允許開始計時(IT1=1)     TH1 = 0xfD;  //FB 18.432MHz 9600 波特率     TL1 = 0xfD;  //fd 11.0592 9600     IE = 0X90;     //EA=ES=1     TR1 = 1;     //啟動定時器     WDT_CONTR = 0x3c;//使能看門狗     p_U2270B_Standby = 0;//單電源     PCON = 0x00;    IP = 0x10;//uart you xian XXXPS PT1 PX1 PT0 PX0     led_light1 = 1;    led_light = 0;    p_U2270B_OutPut = 1;    }    /************************************************/    void f_readcard()//讀卡     {    EA = 0;//全關,防止影響跳變的定時器計時     WDT_CONTR = 0X3C;//喂狗     p_U2270B_CFE = 1;//      delay_2(232);  //>2.5ms            /*   //   aor    用喚醒功能來防碰撞   p_U2270B_CFE = 0; delay_2(18);//start gap>150us   write_bit(1);//10=操作碼讀0頁   write_bit(0);       write_password(&bankdata[24]);//密碼block7   p_U2270B_CFE =1 ;//    delay_2(516);//編程及確認時間5.6ms   */    WDT_CONTR = 0X3C;//喂狗     led_light = 0;    b.W = 0;    while(!(read_ok == 1))    {             //while(p_U2270B_OutPut);//等一個穩定的低電平?超時判斷?              while(!p_U2270B_OutPut);//等待上升沿的到來同步信號檢測1       TR0 = 1;      //deng xia jiang       while(p_U2270B_OutPut);//等待下降沿       TR0 = 0;   a.B.H = TH0;   a.B.L = TL0;   TH0 = TL0 = 0;   TR0 = 1;//定時器晚啟動10個周期       //同步頭       if((324 < a.W) && (a.W < 353)) ;//檢測同步信號1                  else     {     TR0 = 0;     TH0 = TL0 = 0;     goto read_error;    }      //等待上升沿        while(!p_U2270B_OutPut);   TR0 = 0;   a.B.H = TH0;   a.B.L = TL0;   TH0 = TL0 = 0;   TR0 = 1;//b.N1<<=8;            if(a.B.L < 195);//0.5p       else     {     TR0 = 0;     TH0 = TL0 = 0;     goto read_error;    }      //讀0~7塊的數據       for(j = 0;j < 28;j++)      {       //uchar i;                  for(i = 0;i < 16;i++)//8個位        {        //等待下降沿的到來         while(p_U2270B_OutPut);                TR0 = 0;     a.B.H = TH0;     a.B.L = TL0;     TH0 = TL0 = 0;     TR0 = 1;              if(t2_max < a.W/*)&&(a.W < t2_max)*/)//1P          {         b.W >>= 2;//先左移再賦值          b.B.L += 0xc0;                             i++;        }        else if(t1_min < a.B.L/*)&&(a.B.L < t1_max)*/)//0.5p         {         b.W >>= 1;         b.B.L += 0x80;                           }        else      {      TR0 = 0;      TH0 = TL0 = 0;      goto read_error;     }        i++;        while(!p_U2270B_OutPut);//上升                   TR0 = 0;     a.B.H = TH0;     a.B.L = TL0;     TH0 = TL0 = 0;     TR0 = 1;                      if(t2_min < a.W/*)&&(a.W < t2_max)*/)//1P          {         b.W >>= 2;         i++;        }        else if(t1_min < a.B.L/*a.W)&&(a.B.L < t1_max)*/)//0.5P         //else if(!(a.W==0))         {         b.W >>= 1;         //temp+=0x00;          //led_light1=0;led_light=1;delay_2(40000);         }        else      {      TR0 = 0;      TH0 = TL0 = 0;      goto read_error;     }        i++;       }       //取出奇位        DATA = b.B.L;       BIT13 = BIT7;    BIT12 = BIT5;    BIT11 = BIT3;    BIT10 = BIT1;       DATA = b.B.H;       BIT17 = BIT7;    BIT16 = BIT5;    BIT15 = BIT3;    BIT14 = BIT1;       bankdata[j] = DATA1;      }              read_ok = 1;//讀卡完成了     read_error:    _nop_();    }       }    /***************************************************/    void f_writecard(uchar x)//寫卡     {    p_U2270B_CFE = 1;    delay_2(232);  //>2.5ms            //psw=0 standard write     if (x == write_command0)//寫密碼:初始化密碼     {      uchar i;      uchar data *data p;      p = cominceptbuff;      p_U2270B_CFE = 0;   delay_2(31);//start gap>330us       write_bit(1);//寫操作碼1:10       write_bit(0);//寫操作碼0       write_bit(0);//寫鎖定位0       for(i = 0;i < 35;i++)      {       write_bit(1);//寫數據位1       }      p_U2270B_CFE = 1;      led_light1 = 0;   led_light = 1;   delay_2(40000);//測試使用       //write_block(cominceptbuff[4],p);       p_U2270B_CFE = 1;      bankdata[20] = cominceptbuff[0];//密碼存入       bankdata[21] = cominceptbuff[1];      bankdata[22] = cominceptbuff[2];      bankdata[23] = cominceptbuff[3];    }    else if (x == write_command1)//配置卡參數:初始化     {      uchar data *data p;      p = cominceptbuff;      write_bit(1);//寫操作碼1:10       write_bit(0);//寫操作碼0       write_bit(0);//寫鎖定位0               write_block(cominceptbuff[4],p);      p_U2270B_CFE=  1;    }    //psw=1  pssword mode     else if(x == write_command2)  //密碼寫數據    {      uchar data*data p;      p = &bankdata[24];      write_bit(1);//寫操作碼1:10       write_bit(0);//寫操作碼0       write_password(p);//發口令       write_bit(0);//寫鎖定位0       p = cominceptbuff;      write_block(cominceptbuff[4],p);//寫數據            }    else if(x == write_command3)//aor    //喚醒 {      //cominceptbuff[1]操作碼10 X xxxxxB       uchar data *data p;      p = cominceptbuff;      write_bit(1);//10       write_bit(0);             write_password(p);//密碼       p_U2270B_CFE = 1;//此時數據不停的循環傳出     }    else //停止操作碼     {      write_bit(1);//11       write_bit(1);             p_U2270B_CFE = 1;         }    p_U2270B_CFE = 1;    delay_2(560);//5.6ms     }    /************************************/    void f_clearpassword()//清除密碼     {    uchar data *data p;    uchar i,x;          p = &bankdata[24];//原密碼     p_U2270B_CFE = 0; delay_2(18);//start gap>150us     //操作碼10:10xxxxxxB     write_bit(1);    write_bit(0);              for(x = 0;x < 4;x++)//發原密碼     {             DATA = *(p++);      for(i = 0;i < 8;i++)      {       write_bit(BIT0);       DATA >>= 1;      }    }    write_bit(0);//鎖定位0:0     p = &cominceptbuff[0];    write_block(0x00,p);//寫新配置參數:pwd=0             //密碼無效:即清除密碼     DATA = 0x00;//停止操作碼00000000B     for(i = 0;i < 2;i++)    {    write_bit(BIT7);    DATA <<= 1;    }    p_U2270B_CFE = 1;       delay_2(560);//5.6ms     }    /*********************************/    void f_changepassword()//修改密碼            {       uchar data *data p;    uchar i,x,addr;    addr = 0x07;//block7     p = &Nkey_a[0];//原密碼     DATA = 0x80;//操作碼10:10xxxxxxB     for(i = 0;i < 2;i++)    {      write_bit(BIT7);      DATA <<= 1;    }    for(x = 0;x < 4;x++)//發原密碼     {             DATA = *(p++);      for(i = 0;i < 8;i++)      {       write_bit(BIT7);       DATA >>= 1;      }    }    write_bit(0);//鎖定位0:0     p = &cominceptbuff[0];    write_block(0x07,p);//寫新密碼     p_U2270B_CFE = 1;    bankdata[24] = cominceptbuff[0];//密碼存入     bankdata[25] = cominceptbuff[1];    bankdata[26] = cominceptbuff[2];    bankdata[27] = cominceptbuff[3];    DATA = 0x00;//停止操作碼00000000B     for(i = 0;i < 2;i++)    {      write_bit(BIT7);      DATA <<= 1;    }    p_U2270B_CFE = 1;       delay_2(560);//5.6ms     }    /***************************子函數***********************************/    void write_bit(bit x)//寫一位     {    if(x)    {      p_U2270B_CFE = 1;   delay_2(32);//448*11.0592/120=42延時448us       p_U2270B_CFE = 0;   delay_2(28);//280*11.0592/120=26寫1     }    else    {      p_U2270B_CFE = 1;   delay_2(92);//192*11.0592/120=18       p_U2270B_CFE = 0;   delay_2(28);//280*11.0592/120=26寫0     }    }    /*******************寫一個block*******************/    void write_block(uchar addr,uchar data *data p)    {    uchar i,j;        for(i = 0;i < 4;i++)//block0數據     {             DATA = *(p++);      for(j = 0;j < 8;j++)      {       write_bit(BIT0);       DATA >>= 1;      }    }    DATA = addr <<= 5;//0地址     for(i = 0;i < 3;i++)    {      write_bit(BIT7);      DATA <<= 1;    }                   }    /*************************************************/    void write_password(uchar data *data p)    {    uchar i,j;        for(i = 0;i < 4;i++)//     {             DATA = *(p++);      for(j = 0;j < 8;j++)      {       write_bit(BIT0);       DATA >>= 1;      }    }        }   /*************************************************/   void Main()    {    initial();    TI = RI = 0;    ES = 1;    EA = 1;  delay_2(28);   //f_readcard();     while(1) {   f_readcard();      //讀卡   f_writecard(command1);  //寫卡    f_clearpassword();   //清除密碼     f_changepassword();    //修改密碼 } }

    標簽: 12345

    上傳時間: 2017-10-20

    上傳用戶:my_lcs

  • 一個按鍵控制的 10 級變速跑馬燈試驗

    在本課中,我們要用一個按鍵來實現跑馬燈的 10 級調速。這又會涉及到鍵的去抖的問 題。  本課的試驗結果是,每按一次按鍵,跑馬速度就降低一級,共 10 級。  這里我們又增加了一個變量 speedlever,來保存當前的速度檔次。  在按鍵里的處理中,多了當前檔次的延時值的設置。  請看程序:  ――――――――――――――――  #define uchar unsigned char //定義一下方便使用  #define uint unsigned int  #define ulong unsigned long  #include <reg52.h> //包括一個 52 標準內核的頭文件    sbit P10 = P1^0; //頭文件中沒有定義的 IO 就要自己來定義了  sbit P11 = P1^1;  sbit P12 = P1^2;  sbit P13 = P1^3;  sbit K1= P3^2;    bit ldelay=0; //長定時溢出標記,預置是 0  uchar speed=10; //設置一個變量保存默認的跑馬燈的移動速度  uchar speedlever=0; //保存當前的速度檔次    char code dx516[3] _at_ 0x003b;//這是為了仿真設置的  //一個按鍵控制的 10 級變速跑馬燈試驗  void Main(void) // 主程序  {   uchar code ledp[4]={0xfe,0xfd,0xfb,0xf7};//預定的寫入 P1 的值   uchar ledi; //用來指示顯示順序   uint n;     RCAP2H =0x10; //賦 T2 的預置值 0x1000,溢出 30 次就是 1 秒鐘   RCAP2L =0x00;   TR2=1; //啟動定時器   ET2=1; //打開定時器 2 中斷   EA=1; //打開總中斷     while(1) //主程序循環   {   if(ldelay) //發現有時間溢出標記,進入處理   {   ldelay=0; //清除標記   P1=ledp[ledi]; //讀出一個值送到 P1 口   ledi++; //指向下一個   if(ledi==4)   {   ledi=0; //到了最后一個燈就換到第一個   }   }   if(!K1) //如果讀到 K1 為 0   {   for(n=0;n<1000;n++); //等待按鍵穩定   while(!K1); //等待按鍵松開   for(n=0;n<1000;n++); //等待按鍵穩定松開     speedlever++;   if(speedlever==10)speedlever=0;   speed=speedlever*3; //檔次和延時之間的預算法則,也可以用查表方法,做出 不規則的法則   }   }  }  //定時器 2 中斷  timer2() interrupt 5  {   static uchar t;   TF2=0;   t++;     if((t==speed)||(t>30)) //比較一個變化的數值,以實現變化的時間溢出,同時限制了最慢速 度為 1 秒   {   t=0;   ldelay=1;//每次長時間的溢出,就置一個標記,以便主程序處理   }  }  ――――――――――――――――――――――   請打開 lesson11 目錄的工程,編譯,運行,看結果:  按 K1,速度則降低一次,總共 10 個檔次。 

    標簽: 10 按鍵控制 變速 跑馬燈

    上傳時間: 2017-11-06

    上傳用戶:szcyclone

  • 模擬 PWM 輸出控制燈的 10 個亮度級別

    LED 一般是恒流操作的,如何改變 LED 的亮度呢?答案就是 PWM 控制。在一定的 頻率的方波中,調整高電平和低電平的占空比,即可實現。比如我們用低電平點亮一個 LED 燈,我們假設把一個頻率周期分為 10 個時間等份,如果方波中的高低電平占空比是 9:1, 這是就是一個比較暗的亮度,如果方波中高低電平占空比是 10:0,這時,全部是高電平, 燈是滅的。如果占空比是 5:5,就是一個中間亮度,如果高低比是 1:9,是一個比較亮的 亮度,如果高低是 0:10,這時全部是低電平,就是最亮的。  實際上應用中,電視屏幕墻中的幾十百萬 LED 象素都是這樣控制的,而且每一個象素 都有紅綠藍 3 個 LED,每個 LED 可以變化的亮度是幾百到幾萬或者更多的級別,以實現真 彩色的顯示。還有在您的手機中,背光燈的亮度如果是可以變化的,也應該是這種工作方式。 目前的城市彩燈也有很多都使用了 LED,需要控制亮度是也是 PWM 控制。  下面來分析我們的例程,在這個例程中,我們將定時器 2 溢出定為 1/1200 秒。每 10 次脈沖輸出一個 120HZ 頻率。這每 10 次脈沖再用來控制高低電平的 10 個比值。這樣,在 每個 1/120 秒的方波周期中,我們都可以改變方波的輸出占空比,從而控制 LED 燈的 10 個 級別的亮度。  為什么輸出方波的頻率要 120HZ 這么高?因為如果頻率太低,人眼就會看到閃爍感 覺。一般起碼要在 60HZ 以上才感覺好點,120HZ 就基本上看不到閃爍,只能看到亮度的變 化了。  下面請看程序,程序中有比較多的注釋:  ―――――――――――――――――――――――  #define uchar unsigned char //定義一下方便使用  #define uint unsigned int  #define ulong unsigned long  #include <reg52.h> //包括一個 52 標準內核的頭文件    sbit P10 = P1^0; //要控制的 LED 燈  sbit K1= P3^2; //按鍵 K1    uchar scale;//用于保存占空比的輸出 0 的時間份額,總共 10 份    char code dx516[3] _at_ 0x003b;//這是為了仿真設置的  //模擬 PWM 輸出控制燈的 10 個亮度級別  void Main(void) // 主程序  {   uint n;     RCAP2H =0xF3; //賦 T2 的預置值,溢出 1 次是 1/1200 秒鐘   RCAP2L =0x98;   TR2=1; //啟動定時器   ET2=1; //打開定時器 2 中斷   EA=1; //打開總中斷   while(1) //程序循環   { ;//主程序在這里就不斷自循環,實際應用中,這里是做主要工作   for(n=0;n<50000;n++); //每過一會兒就自動加一個檔次的亮度   scale++;   if(scale==10)scale=0;   }  }  //1/1200 秒定時器 2 中斷  timer2() interrupt 5  {   static uchar tt; //tt 用來保存當前時間在一秒中的比例位置   TF2=0;     tt++;   if(tt==10) //每 1/120 秒整開始輸出低電平   {   tt=0;     if(scale!=0) //這里加這一句是為了消除滅燈狀態產生的鬼影   P10=0;   }     if(scale==tt) //按照當前占空比切換輸出高電平   P10=1;    }  ――――――――――――――――――  在主程序中,每延時一段時間,就自動換一個占空比,以使亮度自動變化,方便觀察。  編譯,運行,看結果。  可以看到,LED 的亮度以每種亮度 1 秒左右不斷變化,共有 10 個級別。

    標簽: PWM 10 模擬 控制燈 亮度 輸出

    上傳時間: 2017-11-06

    上傳用戶:szcyclone

  • java入門編程合集

    題目:古典問題:有一對兔子,從出生后第3個月起每個月都生一對兔子,小兔子長到第三個月后每個月又生一對兔子,假如兔子都不死,問每個月的兔子總數為多少?    //這是一個菲波拉契數列問題 public class lianxi01 { public static void Main(String[] args) { System.out.println("第1個月的兔子對數:    1"); System.out.println("第2個月的兔子對數:    1"); int f1 = 1, f2 = 1, f, M=24;      for(int i=3; i<=M; i++) {       f = f2;       f2 = f1 + f2;       f1 = f;       System.out.println("第" + i +"個月的兔子對數: "+f2);          } } } 【程序2】    題目:判斷101-200之間有多少個素數,并輸出所有素數。 程序分析:判斷素數的方法:用一個數分別去除2到sqrt(這個數),如果能被整除, 則表明此數不是素數,反之是素數。    public class lianxi02 { public static void Main(String[] args) {     int count = 0;     for(int i=101; i<200; i+=2) {      boolean b = false;      for(int j=2; j<=Math.sqrt(i); j++)      {         if(i % j == 0) { b = false; break; }          else           { b = true; }      }         if(b == true) {count ++;System.out.println(i );}                                   }     System.out.println( "素數個數是: " + count); } } 【程序3】    題目:打印出所有的 "水仙花數 ",所謂 "水仙花數 "是指一個三位數,其各位數字立方和等于該數本身。例如:153是一個 "水仙花數 ",因為153=1的三次方+5的三次方+3的三次方。 public class lianxi03 { public static void Main(String[] args) {      int b1, b2, b3; 

    標簽: java 編程

    上傳時間: 2017-12-24

    上傳用戶:Ariza

  • 編寫一個程序,要求用戶輸入一年12個月每月的降雨總量,并采用一個float數組存儲。

    程序顯示: 一年內總降雨量、平均每月的降雨量、降雨量最大的月份和最小的月份。 #include<iostream> using namespace std; #include<stdlib.h> int Main() .. .. .. cout<<"降雨量最小的月份是:"<<minyue<<"月   "<<"降雨量為:"<<min<<endl; }

    標簽: float 編寫 程序 用戶 數組 存儲 輸入

    上傳時間: 2018-03-27

    上傳用戶:shayusha

  • 數據結構實驗

    #include <stdio.h>   #include <stdlib.h> ///鏈式棧      typedef struct node   {       int data;       struct node *next;   }Node,*Linklist;      Linklist Createlist()   {       Linklist p;       Linklist h;       int data1;       scanf("%d",&data1);       if(data1 != 0)       {           h = (Node *)malloc(sizeof(Node));           h->data = data1;           h->next = NULL;       }       else if(data1 == 0)       return NULL;       scanf("%d",&data1);       while(data1 != 0)       {           p = (Node *)malloc(sizeof(Node));           p -> data = data1;           p -> next = h;           h = p;           scanf("%d",&data1);       }       return h;   }      void Outputlist(Node *head)   {       Linklist p;       p = head;       while(p != NULL )       {           printf("%d ",p->data);           p = p->next;       }       printf("\n");   }      void Freelist(Node *head)   {       Node *p;       Node *q = NULL;       p = head;       while(p != NULL)       {           q = p;           p = p->next;           free(q);       }   }      int Main()   {       Node *head;       head = Createlist();          Outputlist(head);          Freelist(head);          return 0;   }   2.順序棧 [cpp] view plain copy #include <iostream>   #include <stdio.h>   #include <stdlib.h> ///順序棧   #define MaxSize 100      using namespace std;      typedef

    標簽: 數據結構 實驗

    上傳時間: 2018-05-09

    上傳用戶:123456..

  • 數據結構實驗

    #include <iostream> #include <stdio.head> #include <stdlib.head> #include <string.head> #define ElemType int #define max 100 using namespace std; typedef struct node1 { ElemType data; struct node1 *next; }Node1,*LinkList;//鏈棧 typedef struct { ElemType *base; int top; }SqStack;//順序棧 typedef struct node2 { ElemType data; struct node2 *next; }Node2,*LinkQueue; typedef struct node22 { LinkQueue front; LinkQueue rear; }*LinkList;//鏈隊列 typedef struct { ElemType *base; int front,rear; }SqQueue;//順序隊列 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 //1.采用鏈式存儲實現棧的初始化、入棧、出棧操作。 LinkList CreateStack()//創建棧 { LinkList top; top=NULL; return top; } bool StackEmpty(LinkList s)//判斷棧是否為空,0代表空 { if(s==NULL) return 0; else return 1; } LinkList Pushead(LinkList s,int x)//入棧 { LinkList q,top=s; q=(LinkList)malloc(sizeof(Node1)); q->data=x; q->next=top; top=q; return top; } LinkList Pop(LinkList s,int &e)//出棧 { if(!StackEmpty(s)) { printf("棧為空。"); } else { e=s->data; LinkList p=s; s=s->next; free(p); } return s; } void DisplayStack(LinkList s)//遍歷輸出棧中元素 { if(!StackEmpty(s)) printf("棧為空。"); else { wheadile(s!=NULL) { cout<<s->data<<" "; s=s->next; } cout<<endl; } } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 //2.采用順序存儲實現棧的初始化、入棧、出棧操作。 int StackEmpty(int t)//判斷棧S是否為空 { SqStack.top=t; if (SqStack.top==0) return 0; else return 1; } int InitStack() { SqStack.top=0; return SqStack.top; } int pushead(int t,int e) { SqStack.top=t; SqStack.base[++SqStack.top]=e; return SqStack.top; } int pop(int t,int *e)//出棧 { SqStack.top=t; if(!StackEmpty(SqStack.top)) { printf("棧為空."); return SqStack.top; } *e=SqStack.base[s.top]; SqStack.top--; return SqStack.top; } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 //3.采用鏈式存儲實現隊列的初始化、入隊、出隊操作。 LinkList InitQueue()//創建 { LinkList head; head->rear=(LinkQueue)malloc(sizeof(Node)); head->front=head->rear; head->front->next=NULL; return head; } void deleteEle(LinkList head,int &e)//出隊 { LinkQueue p; p=head->front->next; e=p->data; head->front->next=p->next; if(head->rear==p) head->rear=head->front; free(p); } void EnQueue(LinkList head,int e)//入隊 { LinkQueue p=(LinkQueue)malloc(sizeof(Node)); p->data=e; p->next=NULL; head->rear->next=p; head->rear=p; } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 //4.采用順序存儲實現循環隊列的初始化、入隊、出隊操作。 bool InitQueue(SqQueue &head)//創建隊列 { head.data=(int *)malloc(sizeof(int)); head.front=head.rear=0; return 1; } bool EnQueue(SqQueue &head,int e)//入隊 { if((head.rear+1)%MAXQSIZE==head.front) { printf("隊列已滿\n"); return 0; } head.data[head.rear]=e; head.rear=(head.rear+1)%MAXQSIZE; return 1; } int QueueLengthead(SqQueue &head)//返回隊列長度 { return (head.rear-head.front+MAXQSIZE)%MAXQSIZE; } bool deleteEle(SqQueue &head,int &e)//出隊 { if(head.front==head.rear) { cout<<"隊列為空!"<<endl; return 0; } e=head.data[head.front]; head.front=(head.front+1)%MAXQSIZE; return 1; } int gethead(SqQueue head)//得到隊列頭元素 { return head.data[head.front]; } int QueueEmpty(SqQueue head)//判斷隊列是否為空 { if (head.front==head.rear) return 1; else return 0; } void travelQueue(SqQueue head)//遍歷輸出 { wheadile(head.front!=head.rear) { printf("%d ",head.data[head.front]); head.front=(head.front+1)%MAXQSIZE; } cout<<endl; } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 //5.在主函數中設計一個簡單的菜單,分別測試上述算法。 int Main() { LinkList top=CreateStack(); int x; wheadile(scanf("%d",&x)!=-1) { top=Pushead(top,x); } int e; wheadile(StackEmpty(top)) { top=Pop(top,e); printf("%d ",e); }//以上是鏈棧的測試 int top=InitStack(); int x; wheadile(cin>>x) top=pushead(top,x); int e; wheadile(StackEmpty(top)) { top=pop(top,&e); printf("%d ",e); }//以上是順序棧的測試 LinkList Q; Q=InitQueue(); int x; wheadile(scanf("%d",&x)!=-1) { EnQueue(Q,x); } int e; wheadile(Q) { deleteEle(Q,e); printf("%d ",e); }//以上是鏈隊列的測試 SqQueue Q1; InitQueue(Q1); int x; wheadile(scanf("%d",&x)!=-1) { EnQueue(Q1,x); } int e; wheadile(QueueEmpty(Q1)) { deleteEle(Q1,e); printf("%d ",e); } return 0; }

    標簽: 數據結構 實驗

    上傳時間: 2018-05-09

    上傳用戶:123456..

  • 道理特分解法

    #include "iostream" using namespace std; class Matrix { private: double** A; //矩陣A double *b; //向量b public: int size; Matrix(int ); ~Matrix(); friend double* Dooli(Matrix& ); void Input(); void Disp(); }; Matrix::Matrix(int x) { size=x; //為向量b分配空間并初始化為0 b=new double [x]; for(int j=0;j<x;j++) b[j]=0; //為向量A分配空間并初始化為0 A=new double* [x]; for(int i=0;i<x;i++) A[i]=new double [x]; for(int m=0;m<x;m++) for(int n=0;n<x;n++) A[m][n]=0; } Matrix::~Matrix() { cout<<"正在析構中~~~~"<<endl; delete b; for(int i=0;i<size;i++) delete A[i]; delete A; } void Matrix::Disp() { for(int i=0;i<size;i++) { for(int j=0;j<size;j++) cout<<A[i][j]<<" "; cout<<endl; } } void Matrix::Input() { cout<<"請輸入A:"<<endl; for(int i=0;i<size;i++) for(int j=0;j<size;j++){ cout<<"第"<<i+1<<"行"<<"第"<<j+1<<"列:"<<endl; cin>>A[i][j]; } cout<<"請輸入b:"<<endl; for(int j=0;j<size;j++){ cout<<"第"<<j+1<<"個:"<<endl; cin>>b[j]; } } double* Dooli(Matrix& A) { double *Xn=new double [A.size]; Matrix L(A.size),U(A.size); //分別求得U,L的第一行與第一列 for(int i=0;i<A.size;i++) U.A[0][i]=A.A[0][i]; for(int j=1;j<A.size;j++) L.A[j][0]=A.A[j][0]/U.A[0][0]; //分別求得U,L的第r行,第r列 double temp1=0,temp2=0; for(int r=1;r<A.size;r++){ //U for(int i=r;i<A.size;i++){ for(int k=0;k<r-1;k++) temp1=temp1+L.A[r][k]*U.A[k][i]; U.A[r][i]=A.A[r][i]-temp1; } //L for(int i=r+1;i<A.size;i++){ for(int k=0;k<r-1;k++) temp2=temp2+L.A[i][k]*U.A[k][r]; L.A[i][r]=(A.A[i][r]-temp2)/U.A[r][r]; } } cout<<"計算U得:"<<endl; U.Disp(); cout<<"計算L的:"<<endl; L.Disp(); double *Y=new double [A.size]; Y[0]=A.b[0]; for(int i=1;i<A.size;i++ ){ double temp3=0; for(int k=0;k<i-1;k++) temp3=temp3+L.A[i][k]*Y[k]; Y[i]=A.b[i]-temp3; } Xn[A.size-1]=Y[A.size-1]/U.A[A.size-1][A.size-1]; for(int i=A.size-1;i>=0;i--){ double temp4=0; for(int k=i+1;k<A.size;k++) temp4=temp4+U.A[i][k]*Xn[k]; Xn[i]=(Y[i]-temp4)/U.A[i][i]; } return Xn; } int Main() { Matrix B(4); B.Input(); double *X; X=Dooli(B); cout<<"~~~~解得:"<<endl; for(int i=0;i<B.size;i++) cout<<"X["<<i<<"]:"<<X[i]<<" "; cout<<endl<<"呵呵呵呵呵"; return 0; } 

    標簽: 道理特分解法

    上傳時間: 2018-05-20

    上傳用戶:Aa123456789

主站蜘蛛池模板: 沧州市| 桃源县| 峨眉山市| 曲阳县| 英德市| 来宾市| 固安县| 彝良县| 沁水县| 宜丰县| 绵竹市| 高台县| 五家渠市| 锡林郭勒盟| 册亨县| 上高县| 咸阳市| 阳城县| 韶山市| 板桥市| 平定县| 尚志市| 郴州市| 牟定县| 营山县| 南郑县| 平乐县| 公安县| 贵港市| 鄂尔多斯市| 太原市| 昔阳县| 时尚| 若尔盖县| 通州区| 铜鼓县| 定远县| 柞水县| 富川| 阿拉善右旗| 图们市|