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

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

string

string是C++、java、VB等編程語言中的字符串,字符串是一個特殊的對象,屬于引用類型。在java、C#中,string類對象創建后,字符串一旦初始化就不能更改,因為string類中所有字符串都是常量,數據是無法更改,由于string對象的不可變,所以可以共享。對string類的任何改變,都是返回一個新的string類對象。C++標準庫中string類以類型的形式對字符串進行封裝,且包含了字符序列的處理操作。[1-2]
  • 學生成績查詢

    #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

    標簽: 查詢學會少年宮

    上傳時間: 2016-12-29

    上傳用戶:767483511

  • 學生成績管理啊

    #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(); }

    標簽: 學生專用

    上傳時間: 2016-12-29

    上傳用戶:767483511

  • java學生數據庫

    /*import java.util.Scanner; //主類 public class student122 {   //主方法   public static void main(string[] args){     //定義7個元素的字符數組     string[] st = new string[7];     inputSt(st);       //調用輸入方法     calculateSt(st);   //調用計算方法     outputSt(st);      //調用輸出方法   }   //其他方法   //輸入方法 private static void inputSt(string st[]){     System.out.println("輸入學生的信息:");   System.out.println("學號 姓名 成績1,2,3");   //創建鍵盤輸入類   Scanner ss = new Scanner(System.in);   for(int i=0; i<5; i++){     st[i] = ss.next(); //鍵盤輸入1個字符串   } }   //計算方法 private static void calculateSt(string[] st){   int sum = 0;         //總分賦初值 int ave = 0;         //平均分賦初值 for(int i=2;i<5;i++) {   /計總分,字符變換成整數后進行計算   sum += Integer.parseInt(st[i]); } ave = sum/3;         //計算平均分 //整數變換成字符后保存到數組里 st[5] = string.valueOf(sum); st[6] = string.valueOf(ave); }   //輸出方法 private static void outputSt(string[] st){     System.out.print("學號 姓名 ");   //不換行   System.out.print("成績1 成績2 成績3 ");   System.out.println("總分 平均分");//換行   //輸出學生信息   for(int i=0; i<7; i++){     //按格式輸出,小于6個字符,補充空格     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("輸入學生信息:"); System.out.println("班級 學號 姓名 成績:數學 物理 化學"); //創建鍵盤輸入類 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("序號 班級 學號 姓名 成績:數學 物理 化學 總分 平均分"); //輸出學生信息 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(); } }     //計算方法     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);     } }

    標簽: java 數據庫

    上傳時間: 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//密碼寫數據     #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

  • 聲明病人 Patient 類,

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

    標簽: allergies Patient name age sex tostring boolean setName string weight

    上傳時間: 2017-11-27

    上傳用戶:x138178

  • 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

  • 數據結構實驗

    #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..

  • sha算法

    SHA1(Input: string)

    標簽: sha 算法

    上傳時間: 2019-03-01

    上傳用戶:gbhui21

  • 成績查詢系統

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

    標簽: 成績查詢系統

    上傳時間: 2019-06-08

    上傳用戶:啊的撒旦

主站蜘蛛池模板: 荔浦县| 太仆寺旗| 萨迦县| 高唐县| 彭阳县| 阳西县| 方正县| 马鞍山市| 嘉禾县| 白城市| 泊头市| 沽源县| 木兰县| 南澳县| 弋阳县| 剑阁县| 龙江县| 石狮市| 宣汉县| 南通市| 韶山市| 海安县| 台南县| 灵台县| 建水县| 蓝田县| 个旧市| 安多县| 会东县| 五河县| 凉山| 沈丘县| 彩票| 莒南县| 鄱阳县| 尤溪县| 定远县| 普洱| 天等县| 华池县| 吴江市|