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

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

String

String是C++、java、VB等編程語言中的字符串,字符串是一個(gè)特殊的對象,屬于引用類型。在java、C#中,String類對象創(chuàng)建后,字符串一旦初始化就不能更改,因?yàn)?b>String類中所有字符串都是常量,數(shù)據(jù)是無法更改,由于String對象的不可變,所以可以共享。對String類的任何改變,都是返回一個(gè)新的String類對象。C++標(biāo)準(zhǔn)庫中String類以類型的形式對字符串進(jìn)行封裝,且包含了字符序列的處理操作。[1-2]
  • 學(xué)生成績查詢

    #include "String.h" #include "ctype.h" #include "stdio.h" search(char pd[]) {FILE *fp; int time=0,i=0,j=0,add[80],k=0,m; char *ch, str[900]; m=strlen(pd); if((fp=fopen("haha.txt","r"))==NULL) { printf("Cannot open this file\n"); exit(0); } for(;!feof(fp);i++) { str[i]=fgetc(fp); if(tolower(str[i])==tolower(pd[k])) {k++; if(k==m) if(!isalpha(i-m)&&!isalpha((str[i++]=fgetc(fp)))) { time++; add[j]=i-m+1; j++; k=0; } else k=0; } } if(time) { printf("The time is:%d\n",time); printf("The adders is:\n"); for(i=0;i

    標(biāo)簽: 查詢學(xué)會少年宮

    上傳時(shí)間: 2016-12-29

    上傳用戶:767483511

  • 學(xué)生成績管理啊

    #include "String.h" #include "ctype.h" #include "stdio.h" search(char pd[]) {FILE *fp;  int time=0,i=0,j=0,add[80],k=0,m;  char *ch,  str[900];  m=strlen(pd);  if((fp=fopen("haha.txt","r"))==NULL)  {   printf("Cannot open this file\n");   exit(0);  } for(;!feof(fp);i++)  {  str[i]=fgetc(fp);   if(tolower(str[i])==tolower(pd[k]))    {k++;     if(k==m)     if(!isalpha(i-m)&&!isalpha((str[i++]=fgetc(fp))))     {      time++;      add[j]=i-m+1;      j++;      k=0;     }     else k=0;   }  }   if(time)  {   printf("The time is:%d\n",time);   printf("The adders is:\n");   for(i=0;i<j;i++)   printf("%5d",add[i]);   if(i%5==0)   printf("\n");   getch();   fclose(fp);   }   else   printf("Sorry!Cannot find the word(^_^)"); } main() { char pd[10],choose='y'; int flag=1;     while(flag)    {printf("In put the word you want to seqarch:");     scanf("%s",pd);     search(strlwr(pd));     printf("\nWould you want to continue?(Y/N):");     getchar();     scanf("%c",&choose);     if((tolower(choose))=='n')     flag=0;     else flag=1;    }   printf("Thanks for your using!Bye-bye!\n");   getch(); }

    標(biāo)簽: 學(xué)生專用

    上傳時(shí)間: 2016-12-29

    上傳用戶:767483511

  • java學(xué)生數(shù)據(jù)庫

    /*import java.util.Scanner; //主類 public class student122 {   //主方法   public static void main(String[] args){     //定義7個(gè)元素的字符數(shù)組     String[] st = new String[7];     inputSt(st);       //調(diào)用輸入方法     calculateSt(st);   //調(diào)用計(jì)算方法     outputSt(st);      //調(diào)用輸出方法   }   //其他方法   //輸入方法 private static void inputSt(String st[]){     System.out.println("輸入學(xué)生的信息:");   System.out.println("學(xué)號 姓名 成績1,2,3");   //創(chuàng)建鍵盤輸入類   Scanner ss = new Scanner(System.in);   for(int i=0; i<5; i++){     st[i] = ss.next(); //鍵盤輸入1個(gè)字符串   } }   //計(jì)算方法 private static void calculateSt(String[] st){   int sum = 0;         //總分賦初值 int ave = 0;         //平均分賦初值 for(int i=2;i<5;i++) {   /計(jì)總分,字符變換成整數(shù)后進(jìn)行計(jì)算   sum += Integer.parseInt(st[i]); } ave = sum/3;         //計(jì)算平均分 //整數(shù)變換成字符后保存到數(shù)組里 st[5] = String.valueOf(sum); st[6] = String.valueOf(ave); }   //輸出方法 private static void outputSt(String[] st){     System.out.print("學(xué)號 姓名 ");   //不換行   System.out.print("成績1 成績2 成績3 ");   System.out.println("總分 平均分");//換行   //輸出學(xué)生信息   for(int i=0; i<7; i++){     //按格式輸出,小于6個(gè)字符,補(bǔ)充空格     System.out.printf("%6s", st[i]);   }   System.out.println();            //輸出換行 } }*/   import java.util.Scanner;   public class student122 {   public static void main(String[] args) { // TODO 自動生成的方法存根 String[][] st = new String[3][8]; inputSt(st); calculateSt(st); outputSt(st); }   //輸入方法 private static void inputSt(String st[][]) { System.out.println("輸入學(xué)生信息:"); System.out.println("班級 學(xué)號 姓名 成績:數(shù)學(xué) 物理 化學(xué)"); //創(chuàng)建鍵盤輸入類 Scanner ss = new Scanner(System.in); for(int j = 0; j < 3; j++) { for(int i = 0; i < 6; i++) { st[j][i] = ss.next(); } } } //輸出方法 private static void outputSt(String st[][]) { System.out.println("序號 班級 學(xué)號 姓名 成績:數(shù)學(xué) 物理 化學(xué) 總分 平均分"); //輸出學(xué)生信息 for(int j = 0; j < 3; j++) { System.out.print(j+1 + ":"); for(int i = 0; i < 8; i++) { System.out.printf("%6s", st[j][i]); } System.out.println(); } }     //計(jì)算方法     private static void calculateSt(String[][] st)     {      int sum1 = 0;      int sum2 = 0; int sum3 = 0;      int ave1 = 0;      int ave2 = 0;      int ave3 = 0;      for(int i = 3; i < 6; i++)      {      sum1 += Integer.parseInt(st[0][i]);      }      ave1 = sum1/3;           for(int i = 3; i < 6; i++)      {      sum2 += Integer.parseInt(st[1][i]);      }      ave2 = sum2/3;           for(int i = 3; i < 6; i++)      {      sum3 += Integer.parseInt(st[2][i]);      }      ave3 = sum3/3;           st[0][6] = String.valueOf(sum1);      st[1][6] = String.valueOf(sum2);      st[2][6] = String.valueOf(sum3);      st[0][7] = String.valueOf(ave1);      st[1][7] = String.valueOf(ave2);      st[2][7] = String.valueOf(ave3);     } }

    標(biāo)簽: java 數(shù)據(jù)庫

    上傳時(shí)間: 2017-03-17

    上傳用戶:simple

  • 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//密碼寫數(shù)據(jù)     #define    write_command3       3//喚醒     #define    write_command4       4//停止命令     #define    TRUE       1     #define    FALSE      0     #define    OK         0     #define    ERROR      255     //讀卡的時(shí)間參數(shù)us     #define ts_min          250//270*11.0592/12=249//取近似的整數(shù)     #define ts_max          304//330*11.0592/12=304     #define t1_min          73//90*11.0592/12=83:-10調(diào)整     #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     //***********不采用中斷處理:采用查詢的方法讀卡時(shí)關(guān)所有中斷****************/     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;//讀卡成功標(biāo)志     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};     //存儲卡上用戶數(shù)據(jù)(1-7)7*4=28     uchar data cominceptbuff[6] = {1,2,3,4,5,6};//串口接收數(shù)組ram     uchar command; //第一個(gè)命令     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;    //緩存定時(shí)值,因用同一個(gè)定時(shí)器     union HLint { uint W;    struct   {    uchar H;uchar L;   }   B; };//union HLint idata a     union HLint data a;    //緩存定時(shí)值,因用同一個(gè)定時(shí)器     union HLint0 { uint W;    struct {   uchar H;   uchar L; } B; };//union HLint idata a     union HLint0 data b;    /**********************函數(shù)原型*****************/    //讀寫操作     void f_readcard(void);//全部讀出1~7 AOR喚醒     void f_writecard(uchar x);//根據(jù)命令寫不同的內(nèi)容和操作     void f_clearpassword(void);//清除密碼     void f_changepassword(void);//修改密碼     //功能子函數(shù)     void write_password(uchar data *data p);//寫初始密碼或數(shù)據(jù)     void write_block(uchar x,uchar data *data p);//不能用通用指針     void write_bit(bit x);//寫位     /*子函數(shù)區(qū)*****************************************************/    void delay_2(uint x)    //延時(shí),時(shí)間x*10us@12mhz,最小20us@12mhz     {    x--; x--;    while(x)    {      _nop_();      _nop_();      x--;    }    _nop_();//WDT_CONTR=0X3C;不能頻繁的復(fù)位     _nop_();    }    /////////////////////////////////////////////////////////////////////     void initial(void)    {    SCON = 0x50; //串口方式1,允許接收     //SCON  =0x50;     //01010000B:10位異步收發(fā),波特率可變,SM2=0不用接收到有效停止位才RI=1,     //REN=1允許接收     TMOD = 0x21; //定時(shí)器1 定時(shí)方式2(8位),定時(shí)器0 定時(shí)方式1(16位)     TCON = 0x40; //設(shè)定時(shí)器1 允許開始計(jì)時(shí)(IT1=1)     TH1 = 0xfD;  //FB 18.432MHz 9600 波特率     TL1 = 0xfD;  //fd 11.0592 9600     IE = 0X90;     //EA=ES=1     TR1 = 1;     //啟動定時(shí)器     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;//全關(guān),防止影響跳變的定時(shí)器計(jì)時(shí)     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);//編程及確認(rèn)時(shí)間5.6ms   */    WDT_CONTR = 0X3C;//喂狗     led_light = 0;    b.W = 0;    while(!(read_ok == 1))    {             //while(p_U2270B_OutPut);//等一個(gè)穩(wěn)定的低電平?超時(shí)判斷?              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;//定時(shí)器晚啟動10個(gè)周期       //同步頭       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塊的數(shù)據(jù)       for(j = 0;j < 28;j++)      {       //uchar i;                  for(i = 0;i < 16;i++)//8個(gè)位        {        //等待下降沿的到來         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);//寫數(shù)據(jù)位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)//配置卡參數(shù):初始化     {      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)  //密碼寫數(shù)據(jù)    {      uchar data*data p;      p = &bankdata[24];      write_bit(1);//寫操作碼1:10       write_bit(0);//寫操作碼0       write_password(p);//發(fā)口令       write_bit(0);//寫鎖定位0       p = cominceptbuff;      write_block(cominceptbuff[4],p);//寫數(shù)據(jù)            }    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;//此時(shí)數(shù)據(jù)不停的循環(huán)傳出     }    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++)//發(fā)原密碼     {             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);//寫新配置參數(shù):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++)//發(fā)原密碼     {             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     }    /***************************子函數(shù)***********************************/    void write_bit(bit x)//寫一位     {    if(x)    {      p_U2270B_CFE = 1;   delay_2(32);//448*11.0592/120=42延時(shí)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     }    }    /*******************寫一個(gè)block*******************/    void write_block(uchar addr,uchar data *data p)    {    uchar i,j;        for(i = 0;i < 4;i++)//block0數(shù)據(jù)     {             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();    //修改密碼 } }

    標(biāo)簽: 12345

    上傳時(shí)間: 2017-10-20

    上傳用戶:my_lcs

  • 聲明病人 Patient 類,

    1. 聲明病人 Patient 類,此類對象包括 name(String)、sex(char)、age(int)、weight(float)、allergies(boolean)。 聲明 setName 存取及修改方法。在一個(gè)單獨(dú)的類中,聲明測試方法,并生成兩個(gè) Patient 對象,設(shè)置其 狀態(tài)并將其信息顯示在屏幕上。聲明并測試 toString()方法,顯示一個(gè)病人 age、sex、name 及 allergies

    標(biāo)簽: allergies Patient name age sex toString boolean setName String weight

    上傳時(shí)間: 2017-11-27

    上傳用戶:x138178

  • java入門編程合集

    題目:古典問題:有一對兔子,從出生后第3個(gè)月起每個(gè)月都生一對兔子,小兔子長到第三個(gè)月后每個(gè)月又生一對兔子,假如兔子都不死,問每個(gè)月的兔子總數(shù)為多少?    //這是一個(gè)菲波拉契數(shù)列問題 public class lianxi01 { public static void main(String[] args) { System.out.println("第1個(gè)月的兔子對數(shù):    1"); System.out.println("第2個(gè)月的兔子對數(shù):    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 +"個(gè)月的兔子對數(shù): "+f2);          } } } 【程序2】    題目:判斷101-200之間有多少個(gè)素?cái)?shù),并輸出所有素?cái)?shù)。 程序分析:判斷素?cái)?shù)的方法:用一個(gè)數(shù)分別去除2到sqrt(這個(gè)數(shù)),如果能被整除, 則表明此數(shù)不是素?cái)?shù),反之是素?cái)?shù)。    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( "素?cái)?shù)個(gè)數(shù)是: " + count); } } 【程序3】    題目:打印出所有的 "水仙花數(shù) ",所謂 "水仙花數(shù) "是指一個(gè)三位數(shù),其各位數(shù)字立方和等于該數(shù)本身。例如:153是一個(gè) "水仙花數(shù) ",因?yàn)?53=1的三次方+5的三次方+3的三次方。 public class lianxi03 { public static void main(String[] args) {      int b1, b2, b3; 

    標(biāo)簽: java 編程

    上傳時(shí)間: 2017-12-24

    上傳用戶:Ariza

  • 數(shù)據(jù)結(jié)構(gòu)實(shí)驗(yàn)

    #include <stdio.h>   #include <stdlib.h> ///鏈?zhǔn)綏?nbsp;     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

    標(biāo)簽: 數(shù)據(jù)結(jié)構(gòu) 實(shí)驗(yàn)

    上傳時(shí)間: 2018-05-09

    上傳用戶:123456..

  • 數(shù)據(jù)結(jié)構(gòu)實(shí)驗(yàn)

    #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;//鏈隊(duì)列 typedef struct { ElemType *base; int front,rear; }SqQueue;//順序隊(duì)列 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.采用鏈?zhǔn)酱鎯?shí)現(xiàn)棧的初始化、入棧、出棧操作。 LinkList CreateStack()//創(chuàng)建棧 { 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.采用順序存儲實(shí)現(xiàn)棧的初始化、入棧、出棧操作。 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.采用鏈?zhǔn)酱鎯?shí)現(xiàn)隊(duì)列的初始化、入隊(duì)、出隊(duì)操作。 LinkList InitQueue()//創(chuàng)建 { LinkList head; head->rear=(LinkQueue)malloc(sizeof(Node)); head->front=head->rear; head->front->next=NULL; return head; } void deleteEle(LinkList head,int &e)//出隊(duì) { 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)//入隊(duì) { 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.采用順序存儲實(shí)現(xiàn)循環(huán)隊(duì)列的初始化、入隊(duì)、出隊(duì)操作。 bool InitQueue(SqQueue &head)//創(chuàng)建隊(duì)列 { head.data=(int *)malloc(sizeof(int)); head.front=head.rear=0; return 1; } bool EnQueue(SqQueue &head,int e)//入隊(duì) { if((head.rear+1)%MAXQSIZE==head.front) { printf("隊(duì)列已滿\n"); return 0; } head.data[head.rear]=e; head.rear=(head.rear+1)%MAXQSIZE; return 1; } int QueueLengthead(SqQueue &head)//返回隊(duì)列長度 { return (head.rear-head.front+MAXQSIZE)%MAXQSIZE; } bool deleteEle(SqQueue &head,int &e)//出隊(duì) { if(head.front==head.rear) { cout<<"隊(duì)列為空!"<<endl; return 0; } e=head.data[head.front]; head.front=(head.front+1)%MAXQSIZE; return 1; } int gethead(SqQueue head)//得到隊(duì)列頭元素 { return head.data[head.front]; } int QueueEmpty(SqQueue head)//判斷隊(duì)列是否為空 { 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.在主函數(shù)中設(shè)計(jì)一個(gè)簡單的菜單,分別測試上述算法。 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); }//以上是鏈隊(duì)列的測試 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; }

    標(biāo)簽: 數(shù)據(jù)結(jié)構(gòu) 實(shí)驗(yàn)

    上傳時(shí)間: 2018-05-09

    上傳用戶:123456..

  • sha算法

    SHA1(Input: String)

    標(biāo)簽: sha 算法

    上傳時(shí)間: 2019-03-01

    上傳用戶:gbhui21

  • 成績查詢系統(tǒng)

    #include<stdio.h> #include<String.h> #include<stdlib.h> #define N 100 int iNumOfStu=0; struct score   {   float math;   float english;   float computer;   }; struct student   {   int number;   char name[20];   struct score sco;   float average;   }; struct student stu[N]; void print_menu(void);//輸出菜單 void choosemenu(void);//菜單選擇 void input_student1(int);//輸入學(xué)生信息 void input_student2(void);//輸入總函數(shù) void input_student3(int &,int);//判斷學(xué)號是否重復(fù) void input_student4(int,int);//覆蓋原信息 void sort_student3(student s[],int);//按照英語成績排序 void sort_student4(student s[],int);//按照計(jì)算機(jī)成績排序 void sort_student2(student s[],int);//按照數(shù)學(xué)成績排序 void sort_student5(student s[],int);//按照平均成績排序 float input_score2(int);//計(jì)算學(xué)生平均成績 void print_student2(void);//顯示表頭 void print_student3(int);//顯示學(xué)生信息 void print_student1(int);//顯示全部學(xué)生資料 void sort_student1(void);//排序總函數(shù) void menu(void);//菜單調(diào)度總函數(shù) int search_student2(int);//按學(xué)號查詢學(xué)生信息并輸出 void search_student3(int);//按平均分最高查詢并輸出 void search_student1(void);//查詢總函數(shù) void delete_student2(int,int);//刪除學(xué)生信息 void delete_student1(void);//刪除總函數(shù) void change_student2(int);//修改學(xué)生資料 void change_student1(void);//修改總函數(shù) void input_score3(int);//統(tǒng)計(jì)成績 void input_score1(void);//統(tǒng)計(jì)成績總函數(shù) void print_help(void);//輸出幫助信息 void exit_student(void);//退出系統(tǒng) void save_student(student *,int);//保存學(xué)生信息 void main()   {   menu();   } void save_student(student *s,int a)//保存學(xué)生信息   {   FILE *fp;     if((fp=fopen("d:\\學(xué)生信息.txt","wb"))==NULL)       {       printf("不能打開文件!\n");       }     else       {       printf("保存信息到D盤\n");       fprintf(fp,"本班所有學(xué)生具體信息如下:\r\n");       fprintf(fp,"  學(xué)號       姓名           數(shù)學(xué)成績       英語成績     計(jì)算機(jī)成績     平均成績\r\n");       for(int i=0;i<a;i++)         {         fprintf(fp,"%8d%12s%14.2f%14.2f%14.2f%14.2f\n",stu[i].number,stu[i].name,stu[i].sco.math,stu[i].sco.english,stu[i].sco.computer,stu[i].average);         fprintf(fp,"\r\n");         }       fclose(fp);       printf("信息保存成功!\n");       }   } void exit_student(void)//退出系統(tǒng)   {   exit(1);   } void print_help(void)//輸出幫助信息   {   printf("本系統(tǒng)所能容納的最大學(xué)生數(shù)為%d人\n學(xué)生信息保存在D盤根目錄下,保存文件為“學(xué)生信息.txt”。\n感謝使用!\n",N);   } void input_score1(void)//統(tǒng)計(jì)成績總函數(shù)   {   int c;   c=search_student2(iNumOfStu);   printf("學(xué)號:%d\n",stu[c].number);   printf("姓名:%s\n",stu[c].name);   input_score3(c);   printf("新成績錄入成功!\n");   stu[c].average=input_score2(c);   } void input_score3(int a)//統(tǒng)計(jì)成績   {   printf("數(shù)學(xué)新成績:");   scanf("%f",&stu[a].sco.math);   printf("英語新成績:");   scanf("%f",&stu[a].sco.english);   printf("計(jì)算機(jī)新成績:");   scanf("%f",&stu[a].sco.computer);   } void change_student2(int a)//修改學(xué)生資料   {   printf("學(xué)號:%d----修改為:",stu[a].number);   scanf("%d",&stu[a].number);   getchar();   printf("姓名:%s----修改為:",stu[a].name);   gets(stu[a].name);   printf("數(shù)學(xué)成績:%.2f----修改為:",stu[a].sco.math);   scanf("%f",&stu[a].sco.math);   printf("英語成績:%.2f----修改為:",stu[a].sco.english);   scanf("%f",&stu[a].sco.english);   printf("計(jì)算機(jī)成績:%.2f----修改為:",stu[a].sco.computer);   scanf("%f",&stu[a].sco.computer);   } void change_student1(void)//修改總函數(shù)   {   int c;   c=search_student2(iNumOfStu);   getchar();   printf("是否要修改此學(xué)生信息?(“y”代表是)");   char d;   scanf("%c",&d);   if(d=='y'||d=='Y')     {     change_student2(c);       stu[c].average=input_score2(c);     printf("信息修改成功!\n");     }   } void delete_student1(void)//刪除總函數(shù)   {   int c;   c=search_student2(iNumOfStu);   getchar();   printf("是否刪除此條記錄?(“y”代表是)");   char d;   scanf("%c",&d);   if(d=='y'||d=='Y')     {     delete_student2(c,iNumOfStu);     printf("記錄已刪除!\n");     }   } void delete_student2(int a,int b)//刪除學(xué)生信息   {   for(int i=a;i<b-1;i++)     {     stu[i]=stu[i+1];     }   --iNumOfStu;   } void search_student1(void)//查詢總函數(shù)   {   printf("1、按學(xué)號查詢\n2、按平均分最高查詢\n請選擇:");   int c;   scanf("%d",&c);   switch(c)     {     case 1:       {       search_student2(iNumOfStu);       break;       }     case 2:       {       search_student3(iNumOfStu);       break;       }     default: break;     }   } void menu(void)//菜單調(diào)度總函數(shù)   {   print_menu();   choosemenu();   } void sort_student1(void)//排序總函數(shù)   {   printf("1、按數(shù)學(xué)成績排序\n2、按英語成績排序\n3、按計(jì)算機(jī)成績排序\n4、按平均成績排序\n請選擇:");   int c;   scanf("%d",&c);   switch(c)     {     case 1:       {       sort_student2(stu,iNumOfStu);       break;       }     case 2:       {       sort_student3(stu,iNumOfStu);       break;       }     case 3:       {       sort_student4(stu,iNumOfStu);       break;       }     case 4:       {       sort_student5(stu,iNumOfStu);       break;       }     default: break;     }   } void print_student1(int a)//顯示全部學(xué)生資料   {   printf("本班所有學(xué)生具體信息如下\n");   print_student2();   for(int i=0;i<a;i++)     {     print_student3(i);     }   } void print_student3(int a)//顯示學(xué)生信息   {   printf("%8d%12s%14.2f%14.2f%14.2f%14.2f\n",stu[a].number,stu[a].name,stu[a].sco.math,stu[a].sco.english,stu[a].sco.computer,stu[a].average);   } void print_student2(void)//顯示表頭   {   printf("  學(xué)號       姓名           數(shù)學(xué)成績       英語成績     計(jì)算機(jī)成績     平均成績\n");   } void input_student4(int a,int b)//覆蓋原信息   {   stu[a]=stu[b-1];   --iNumOfStu;   } void input_student3(int &a,int b)//判斷學(xué)號是否重復(fù)   {   if(a!=0)     {     int i=0;     do       {       if(stu[a].number==stu[i].number)         {         printf("此學(xué)號代表的學(xué)生已錄入\n1、覆蓋原信息\n2、重新輸入\n請選擇:");         int c;         scanf("%d",&c);         switch(c)           {           case 1:             {             input_student4(i,iNumOfStu);             a=iNumOfStu-1;             printf("信息已替換!\n");             break;             }           case 2:             {             printf("請重新輸入學(xué)生信息:\n");             input_student1(iNumOfStu-1);             break;             }           default: break;           }         break;         }       ++i;       }       while(i<b-1);     }   } void print_menu(void)//輸出菜單   {   printf("======歡迎來到學(xué)生信息管理系統(tǒng)======\n");   printf("      1、輸入學(xué)生資料\n");   printf("      2、刪除學(xué)生資料\n");   printf("      3、查詢學(xué)生資料\n");   printf("      4、修改學(xué)生資料\n");   printf("      5、顯示學(xué)生資料\n");   printf("      6、統(tǒng)計(jì)學(xué)生成績\n");   printf("      7、排序?qū)W生成績\n");   printf("      8、保存學(xué)生資料\n");   printf("      9、獲取幫助信息\n");   printf("      10、退出系統(tǒng)\n");   printf("====================================\n");   printf("請選擇:");   } void input_student2(void)//輸入總函數(shù)   {   char end;   printf("請輸入學(xué)生信息(在最后一個(gè)學(xué)生信息錄入完成后以“/”結(jié)束錄入):\n");   for(int i=0;(end=getchar())!='/';i++)     {     input_student1(i);     ++iNumOfStu;     input_student3(i,iNumOfStu);     }   for(int j=0;j<iNumOfStu;j++)     {     stu[j].average=input_score2(j);     }   } void input_student1(int a)//輸入學(xué)生信息   {   printf("學(xué)號:");   scanf("%d",&stu[a].number);   getchar();   printf("姓名:");   gets(stu[a].name);   printf("數(shù)學(xué)成績:");   scanf("%f",&stu[a].sco.math);   printf("英語成績:");   scanf("%f",&stu[a].sco.english);   printf("計(jì)算機(jī)成績:");   scanf("%f",&stu[a].sco.computer);   } float input_score2(int a)//計(jì)算學(xué)生平均成績   {   return (stu[a].sco.math+stu[a].sco.english+stu[a].sco.computer)/3;   } void search_student3(int a)//按平均分最高查詢并輸出   {   int max=0;   for(int i=0;i<a;i++)     {     if(stu[max].average<stu[i].average)       {       max=i;       }     }   print_student2();   print_student3(max);   } void sort_student2(student s[],int a)//按照數(shù)學(xué)成績排序   {   struct student temp;   for(int i=0;i<a-1;i++)     {     int max=i;     for(int j=i+1;j<a;j++)       if(stu[j].sco.math>stu[max].sco.math)         {         max=j;         }     if(max!=i)       {       temp=stu[max];       stu[max]=stu[i];       stu[i]=temp;       }     }   print_student2();   for(int k=0;k<a;k++)     {     print_student3(k);     }   } void sort_student3(student s[],int a)//按照英語成績排序   {   struct student temp;   for(int i=0;i<a-1;i++)     {     int max=i;     for(int j=i+1;j<a;j++)       if(stu[j].sco.english>stu[max].sco.english)         {         max=j;         }     if(max!=i)       {       temp=stu[max];       stu[max]=stu[i];       stu[i]=temp;       }     }   print_student2();   for(int k=0;k<a;k++)     {     print_student3(k);     }   } void sort_student4(student s[],int a)//按照計(jì)算機(jī)成績排序   {   struct student temp;   for(int i=0;i<a-1;i++)     {     int max=i;     for(int j=i+1;j<a;j++)       if(stu[j].sco.computer>stu[max].sco.computer)         {         max=j;         }     if(max!=i)       {       temp=stu[max];       stu[max]=stu[i];       stu[i]=temp;       }     }   print_student2();   for(int k=0;k<a;k++)     {     print_student3(k);     }   } void sort_student5(student s[],int a)//按照平均成績排序   {   struct student temp;   for(int i=0;i<a-1;i++)     {     int max=i;     for(int j=i+1;j<a;j++)       if(stu[j].average>stu[max].average)         {         max=j;         }     if(max!=i)       {       temp=stu[max];       stu[max]=stu[i];       stu[i]=temp;       }     }   print_student2();   for(int k=0;k<a;k++)     {     print_student3(k);     }   } int search_student2(int a)//按照學(xué)號查找學(xué)生并輸出   {   int num;   int c;   printf("請輸入要查詢的學(xué)號:");   scanf("%d",&num);   for(int i=0;i<a;i++)     {     if(num==stu[i].number)       {       c=i;       }     }   printf("此學(xué)生的信息是:\n");   print_student2();   print_student3(c);   return c;   } void choosemenu(void)//菜單選擇   {   int i;   scanf("%d",&i);   switch(i)     {     case 1:       {       input_student2();       printf("按回車鍵返回主菜單");       getchar();       getchar();       menu();       break;       }     case 2:       {       delete_student1();       printf("按回車鍵返回主菜單");       getchar();       getchar();       menu();       break;       }     case 3:       {       search_student1();       printf("按回車鍵返回主菜單");       getchar();       getchar();       menu();       break;       }     case 4:       {       change_student1();       printf("按回車鍵返回主菜單");       getchar();       getchar();       menu();       break;       }     case 5:       {       print_student1(iNumOfStu);       printf("按回車鍵返回主菜單");       getchar();       getchar();       menu();       break;       }     case 6:       {       input_score1();       printf("按回車鍵返回主菜單");       getchar();       getchar();       menu();       break;       }     case 7:       {       sort_student1();       printf("按回車鍵返回主菜單");       getchar();       getchar();       menu();       break;       }     case 8:       {       save_student(stu,iNumOfStu);       printf("按回車鍵返回主菜單");       getchar();       getchar();       menu();       break;       }     case 9:       {       print_help();       printf("按回車鍵返回主菜單");       getchar();       getchar();       menu();       break;       }     case 10:       {       exit_student();       }     default: break;     }   }         運(yùn)行結(jié)果:                         源文件下載地址: http://115.com/file/clnq138g#一個(gè)簡單的學(xué)生成績管理系統(tǒng).rar (請將此地址復(fù)制到瀏覽器地址欄中訪問下載頁面)  

    標(biāo)簽: 成績查詢系統(tǒng)

    上傳時(shí)間: 2019-06-08

    上傳用戶:啊的撒旦

主站蜘蛛池模板: 个旧市| 玛纳斯县| 大田县| 邹平县| 清镇市| 兴文县| 六盘水市| 进贤县| 南靖县| 金阳县| 嵊泗县| 万源市| 祁东县| 嘉祥县| 娄底市| 邹城市| 登封市| 溧水县| 斗六市| 昌平区| 南郑县| 弋阳县| 油尖旺区| 儋州市| 肥乡县| 平南县| 石柱| 怀仁县| 黄梅县| 双江| 抚松县| 修水县| 怀宁县| 三亚市| 孝昌县| 西畴县| 宽城| 万荣县| 乳山市| 温宿县| 连江县|