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

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

string

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

    關于代碼的解釋(以區為單位): 1區中,當讀取文件時,先把文件內容讀到緩存中,當調用in.readLine()時,再從緩存中以字符的方式讀取數據(以下簡稱“緩存字節讀取方式”)。 1b區中,由于想以緩存字節讀取方式從標準IO(鍵盤)中讀取數據,所以要先把標準IO(System.in)轉換成字符導向的stream,再進行BufferedReader封裝。 2區中,要以字符的形式從一個string對象中讀取數據,所以要產生一個stringReader類型的stream。 4區中,對string對象s2讀取數據時,先把對象中的數據存入緩存中,再從緩沖中進行讀取;對TestIO.out文件進行操作時,先把格式化后的信息輸出到緩存中,再把緩存中的信息輸出到文件中。 5區中,對Data.txt文件進行輸出時,是先把基本類型的數據輸出屋緩存中,再把緩存中的數據輸出到文件中;對文件進行讀取操作時,先把文件中的數據讀取到緩存中,再從緩存中以基本類型的形式進行讀取。注意in5.readDouble()這一行。因為寫入第一個writeDouble(),所以為了正確顯示。也要以基本類型的形式進行讀取。 6區是通過RandomAccessFile類對文件進行操作。

    標簽: 代碼 單位

    上傳時間: 2013-12-28

    上傳用戶:Shaikh

  • the best serial port component for delphi application. you can send receive serial port datas as

    the best serial port component for delphi application. you can send receive serial port datas as byte string or cluster

    標簽: serial port application component

    上傳時間: 2017-09-17

    上傳用戶:1427796291

  • samba服務器實驗指導

    第一節、samba是干什么的?它有什么用? Samba(SMB是其縮寫) 是一個網絡服務器,它是Linux作為本地服務器最重要的一個服務,用于Linux和Windows共享文件之用;Samba可以用于Windows和 Linux之間的共享文件,也一樣用于Linux和Linux之間的共享文件;不過對于Linux和Linux之間共享文件有更好的網絡文件系統 NFS,NFS也是需要架設服務器的; 2、安裝及服務操作命令 安裝samba程序非常簡單,使用rpm -q samba查看當前系統是否已經安裝了samba軟件。 如果沒有那就進入光盤,rpm -ivh *samba*.rpm即可。 仔細說下安裝的包: samba-common-3.0.28-0.el5.8    //samba服務器和客戶端中的最基本文件 samba-3.0.28-0.el5.8           //samba服務器核心軟件包 system-config-samba-1.2.39-1.el5     //samba圖形配置界面 samba-client-3.0.28-0.el5.8          //samba客戶端軟件   啟動、暫停和停止服務: /etc/init.d/smb start /etc/init.d/smb stop /etc/init.d/smb restart 或 service smb start service smb stop service smb restart   第二節、由最簡單的一個例子說起,匿名用戶可讀可寫的實現 第一步: 更改smb.conf 我們來實現一個最簡單的功能,讓所有用戶可以讀寫一個Samba 服務器共享的一個文件夾;我們要改動一下smb.conf ;首先您要備份一下smb.conf文件; [root@localhost ~]# cd /etc/samba [root@localhost samba]# cp smb.conf smb.conf.bak [root@localhost samba]# vi smb.conf 或geidt smb.conf & 然后我們把下面這段寫入smb.conf中:   [global] workgroup = WORKGROUP netbios name = Liukai server string = Liukai's Samba Server security = share [test]         path = /opt/test         writeable = yes         browseable = yes         guest ok = yes 注解: [global]這段是全局配置,是必段寫的。其中有如下的幾行; workgroup 就是Windows中顯示的工作組;在這里我設置的是WORKGROUP (用大寫); netbios name 就是在Windows中顯示出來的計算機名; server string 就是Samba服務器說明,可以自己來定義;這個不是什么重要的; security 這是驗證和登錄方式,這里我們用了share ;驗證方式有好多種,這是其中一種;另外一種常用的是user的驗證方式;如果用share呢,就是不用設置用戶和密碼了; [test] 這個在Windows中顯示出來是共享的目錄; path = 可以設置要共享的目錄放在哪里; writeable 是否可寫,這里我設置為可寫; browseable 是否可以瀏覽,可以;可以瀏覽意味著,我們在工作組下能看到共享文件夾。如果您不想顯示出來,那就設置為 browseable=no,guest ok 匿名用戶以guest身份是登錄; 第二步:建立相應目錄并授權 [root@localhost ~]# mkdir -p /opt/test [root@localhost ~]# id nobody uid=99(nobody) gid=99(nobody) groups=99(nobody) [root@localhost ~]# chown -R nobody:nobody /opt/test 注釋:關于授權nobody,我們先用id命令查看了nobody用戶的信息,發現他的用戶組也是nobody,我們要以這個為準。有些系統nobody用戶組并非是nobody ; 第三步:啟動服務器 第四步:訪問Samba 服務器的共享; 1、在Linux 中您可以用下面的命令來訪問; [root@localhost ~]# smbclient -L //liukai或 smbclient //192.168.0.94/test Password: 注:直接按回車 2、在Windows中,您可以用下面的辦法來訪問; \\liukai  或  \\192.168.0.94 3、說明:如果用了netbiosname,就可以用“\\主機名”來訪問,如果沒用netbiosname,就不能用主機名訪問。   第三節、簡單的密碼驗證服務器 修改smb.conf文件: security = user guest account = liukai encrypt passwords = yes smb passwd file = /etc/samba/smbpasswd 然后,建立一個新用戶 useradd liukai passwd liukai 成功后,cat /etc/passwd | mksmbpasswd.sh > /etc/samba/smbpasswd smbpasswd -a liukai 這就成功地添加了一個smb用戶。 重啟服務,使用這個用戶進行登錄即可。    

    標簽: samba 嵌入式

    上傳時間: 2015-05-13

    上傳用戶:yangkang1192

  • Boost C++ Libraries 1.35.0

    Boost C++ Libraries Free peer-reviewed portable C++ source libraries Boost C++ Libraries 基本上是一個免費的 C++ 的跨平臺函式庫集合,基本上應該可以把它視為 C++ STL 的功能再延伸;他最大的特色在於他是一個經過「同行評審」(peer review,可參考維基百科)、開放原始碼的函式庫,而且有許多 Boost 的函式庫是由 C++ 標準委員會的人開發的,同時部分函式庫的功能也已經成為 C++ TR1 (Technical Report 1,參考維基百科)、TR2、或是 C++ 0x 的標準了。 它的官方網站是:http://www.boost.org/,包含了 104 個不同的 library;由於他提供的函式庫非常地多,的內容也非常地多元,根據官方的分類,大致上可以分為下面這二十類: 字串和文字處理(string and text processing) 容器(Containers) Iterators 演算法(Algorithms) Function objects and higher-order programming 泛型(Generic Programming) Template Metaprogramming Preprocessor Metaprogramming Concurrent Programming 數學與數字(Math and numerics) 正確性與測試(Correctness and testing) 資料結構(Data structures) 影像處理(Image processing) 輸入、輸出(Input/Output) Inter-language support 記憶體(Memory) 語法分析(Parsing) 程式介面(Programming Interfaces) 其他雜項 Broken compiler workarounds 其中每一個分類,又都包含了一個或多個函式庫,可以說是功能相當豐富。

    標簽: Boost C++ Libraries

    上傳時間: 2015-05-15

    上傳用戶:fangfeng

  • 文件Java排課系統的報告

    My JSP 'TeacherMain.jsp' starting page var $=function(id) { return document.getElementById(id); } function show_menu(num){ for(i=0;i

    標簽: C++

    上傳時間: 2015-07-03

    上傳用戶:xiyuzhu

  • C語言用戶注冊及登錄

    #include<stdio.h> #include<stdlib.h> #include<conio.h> #include<string.h> main(void) {   char new_name[4], name[4];     int new_sn ,sn;     printf("        【注冊】\n\n");     printf("請輸入用戶名(四位英文字母):");     scanf("%s", &new_name);     printf("請輸入密碼(六位數字):") ;     scanf("%d" ,&new_sn);    /*system("PAUSE");*/     system("CLS");/*清屏*/        /*system("PAUSE");*/        printf("  【登陸】\n\n");        printf("輸入用戶名:");        scanf("%s" , &name);        if(!strcmp(new_name,name)){printf("輸入用戶名錯誤!"); }/*判斷用戶是否正確*/     printf("輸入密碼:");     scanf("%d" , &sn);     if(new_sn != sn){printf("輸入密碼錯誤!"); }/*判斷密碼是否正確*/     system("CLS");     printf("恭喜你,登陸成功!\n");        getchar();     return 0;     }

    標簽: C語言

    上傳時間: 2015-12-30

    上傳用戶:gjatd1987

  • redis官方手冊翻譯

    Redis 命令參考 1 Key(鍵) 1 1.1 DEL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.2 DUMP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 1.3 EXISTS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 1.4 EXPIRE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 1.5 EXPIREAT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 1.6 KEYS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 1.7 MIGRATE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 1.8 MOVE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 1.9 OBJECT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 1.10 PERSIST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 1.11 PEXPIRE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 1.12 PEXPIREAT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 1.13 PTTL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 1.14 RANDOMKEY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 1.15 RENAME . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 1.16 RENAMENX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 1.17 RESTORE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 1.18 SORT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 1.19 TTL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 1.20 TYPE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 1.21 SCAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 2 string(字符串) 29 2.1 APPEND . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 2.2 BITCOUNT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 2.3 BITOP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 2.4 DECR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 2.5 DECRBY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 2.6 GET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 2.7 GETBIT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 2.8 GETRANGE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 2.9 GETSET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 2.10 INCR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 2.11 INCRBY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 2.12 INCRBYFLOAT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 2.13 MGET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 2.14 MSET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 2.15 MSETNX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 i 2.16 PSETEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 2.17 SET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 2.18 SETBIT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 2.19 SETEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 2.20 SETNX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 2.21 SETRANGE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 2.22 STRLEN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 3 Hash(哈希表) 51 3.1 HDEL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 3.2 HEXISTS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52 3.3 HGET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52 3.4 HGETALL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 3.5 HINCRBY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 3.6 HINCRBYFLOAT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 3.7 HKEYS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 3.8 HLEN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 3.9 HMGET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 3.10 HMSET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 3.11 HSET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 3.12 HSETNX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58 3.13 HVALS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58 3.14 HSCAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 4 List(列表) 61 4.1 BLPOP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 4.2 BRPOP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 4.3 BRPOPLPUSH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 4.4 LINDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 4.5 LINSERT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 4.6 LLEN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 4.7 LPOP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 4.8 LPUSH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 4.9 LPUSHX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 4.10 LRANGE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 4.11 LREM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70 4.12 LSET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 4.13 LTRIM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 4.14 RPOP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 4.15 RPOPLPUSH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 4.16 RPUSH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 4.17 RPUSHX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 5 Set(集合) 79 5.1 SADD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 5.2 SCARD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 5.3 SDIFF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 5.4 SDIFFSTORE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 5.5 SINTER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 5.6 SINTERSTORE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 5.7 SISMEMBER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 5.8 SMEMBERS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 5.9 SMOVE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 5.10 SPOP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84 ii 5.11 SRANDMEMBER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84 5.12 SREM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86 5.13 SUNION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 5.14 SUNIONSTORE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 5.15 SSCAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 6 SortedSet(有序集合) 89 6.1 ZADD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 6.2 ZCARD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90 6.3 ZCOUNT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91 6.4 ZINCRBY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91 6.5 ZRANGE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92 6.6 ZRANGEBYSCORE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93 6.7 ZRANK . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94 6.8 ZREM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94 6.9 ZREMRANGEBYRANK . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 6.10 ZREMRANGEBYSCORE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96 6.11 ZREVRANGE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96 6.12 ZREVRANGEBYSCORE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 6.13 ZREVRANK . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 6.14 ZSCORE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 6.15 ZUNIONSTORE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99 6.16 ZINTERSTORE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 6.17 ZSCAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101 7 Pub/Sub(發布/訂閱) 103 7.1 PSUBSCRIBE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 7.2 PUBLISH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104 7.3 PUBSUB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104 7.4 PUNSUBSCRIBE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 7.5 SUBSCRIBE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 7.6 UNSUBSCRIBE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108 8 Transaction(事務) 109 8.1 DISCARD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109 8.2 EXEC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109 8.3 MULTI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111 8.4 UNWATCH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111 8.5 WATCH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 9 Script(腳本) 113 9.1 EVAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 9.2 EVALSHA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120 9.3 SCRIPT EXISTS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120 9.4 SCRIPT FLUSH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121 9.5 SCRIPT KILL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121 9.6 SCRIPT LOAD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122 10 Connection(連接) 123 10.1 AUTH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123 10.2 ECHO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124 10.3 PING . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124 10.4 QUIT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125 10.5 SELECT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125 iii 11 Server(服務器) 127 11.1 BGREWRITEAOF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127 11.2 BGSAVE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127 11.3 CLIENT GETNAME . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128 11.4 CLIENT KILL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128 11.5 CLIENT LIST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 11.6 CLIENT SETNAME . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130 11.7 CONFIG GET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131 11.8 CONFIG RESETSTAT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133 11.9 CONFIG REWRITE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136 11.10 CONFIG SET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137 11.11 DBSIZE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138 11.12 DEBUG OBJECT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138 11.13 DEBUG SEGFAULT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138 11.14 FLUSHALL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 11.15 FLUSHDB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 11.16 INFO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140 11.17 LASTSAVE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143 11.18 MONITOR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143 11.19 PSYNC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144 11.20 SAVE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144 11.21 SHUTDOWN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144 11.22 SLAVEOF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145 11.23 SLOWLOG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146 11.24 SYNC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147 11.25 TIME . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148 12 鍵空間通知(keyspace notification) 149 12.1 功能概覽. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149 12.2 事件的類型. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149 12.3 配置. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150 12.4 命令產生的通知. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150 12.5 過期通知的發送時間. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152 13 事務(transaction) 153 13.1 用法. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153 13.2 事務中的錯誤. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154 13.3 為什么Redis 不支持回滾(roll back) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155 13.4 放棄事務. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155 13.5 使用check-and-set 操作實現樂觀鎖. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156 13.6 了解WATCH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156 13.7 使用WATCH 實現ZPOP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157 13.8 Redis 腳本和事務. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157 14 發布與訂閱(pub/sub) 159 14.1 信息的格式. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159 14.2 訂閱模式. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160 14.3 通過頻道和模式接收同一條信息. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161 14.4 訂閱總數. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161 14.5 編程示例. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161 14.6 客戶端庫實現提示. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161 15 復制(Replication) 163 15.1 復制功能的運作原理. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163 15.2 部分重同步. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164 iv 15.3 配置. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164 15.4 只讀從服務器. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164 15.5 從服務器相關配置. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165 15.6 主服務器只在有至少N 個從服務器的情況下,才執行寫操作. . . . . . . . . . . . . . . . . . 165 16 通信協議(protocol) 167 16.1 網絡層. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167 16.2 請求. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167 16.3 新版統一請求協議. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167 16.4 回復. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168 16.5 狀態回復. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168 16.6 錯誤回復. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169 16.7 整數回復. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169 16.8 批量回復. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169 16.9 多條批量回復. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170 16.10 多條批量回復中的空元素. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171 16.11 多命令和流水線. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171 16.12 內聯命令. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171 16.13 高性能Redis 協議分析器. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172 17 持久化(persistence) 173 17.1 Redis 持久化. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173 17.2 RDB 的優點. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173 17.3 RDB 的缺點. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174 17.4 AOF 的優點. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174 17.5 AOF 的缺點. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174 17.6 RDB 和AOF ,我應該用哪一個? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175 17.7 RDB 快照. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175 17.8 快照的運作方式. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175 17.9 只進行追加操作的文件(append-only file,AOF) . . . . . . . . . . . . . . . . . . . . . . . . 175 17.10 AOF 重寫. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176 17.11 AOF 有多耐久? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176 17.12 如果AOF 文件出錯了,怎么辦? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176 17.13 AOF 的運作方式. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177 17.14 怎么從RDB 持久化切換到AOF 持久化. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177 17.15 RDB 和AOF 之間的相互作用. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178 17.16 備份Redis 數據. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178 17.17 容災備份. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178 18 Sentinel 181 18.1 獲取Sentinel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181 18.2 啟動Sentinel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181 18.3 配置Sentinel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182 18.4 主觀下線和客觀下線. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183 18.5 每個Sentinel 都需要定期執行的任務. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184 18.6 自動發現Sentinel 和從服務器. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184 18.7 Sentinel API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184 18.8 故障轉移. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186 18.9 TILT 模式. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188 18.10 處理-BUSY 狀態. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188 18.11 Sentinel 的客戶端實現. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189 19 集群教程191 19.1 集群簡介. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191 19.2 Redis 集群數據共享. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191 v 19.3 Redis 集群中的主從復制. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192 19.4 Redis 集群的一致性保證(guarantee) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192 19.5 創建并使用Redis 集群. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193 19.6 創建集群. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194 19.7 集群的客戶端. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195 19.8 使用redis-rb-cluster 編寫一個示例應用. . . . . . . . . . . . . . . . . . . . . . . . . . . . 196 19.9 對集群進行重新分片. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197 19.10 一個更有趣的示例應用. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200 19.11 故障轉移測試. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201 19.12 添加新節點到集群. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202 19.13 移除一個節點. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204 20 Redis 集群規范205 20.1 引言. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205 20.2 什么是Redis 集群? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205 20.3 Redis 集群實現的功能子集. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206 20.4 Redis 集群協議中的客戶端和服務器. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206 20.5 鍵分布模型. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206 20.6 集群節點屬性. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207 20.7 節點握手(已實現) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208 20.8 MOVED 轉向. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208 20.9 集群在線重配置(live reconfiguration) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209 20.10 ASK 轉向. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210 20.11 容錯. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211 20.12 發布/訂閱(已實現,但仍然需要改善) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213 20.13 附錄A:CRC16 算法的ANSI 實現參考. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213 21 關于217 22 通過捐款支持本文檔219

    標簽: redis 官方手冊

    上傳時間: 2016-02-04

    上傳用戶:1987

  • Java api 6.0

    api就是一個幫助文檔,讓您能快速了解java的屬性,方法。加入想對字符串進行操作,就可以去api中查看string的方法,里面會有每個方法的用法,返回值等等。。

    標簽: Java 6.0 api

    上傳時間: 2016-11-30

    上傳用戶:一江春水向東流

  • 運動會源代碼

    #include <malloc.h>       #include <stdio.h>       #include <stdlib.h>       #include <string.h>       #define NULL 0      #define MaxSize 30          typedef struct athletestruct /*運動員*/     {         char name[20];          int score; /*分數*/         int range; /**/         int item; /*項目*/     }ATH;     typedef struct schoolstruct /*學校*/     {         int count; /*編號*/         int serial; /**/          int menscore; /*男選手分數*/         int womenscore; /*女選手分數*/         int totalscore; /*總分*/         ATH athlete[MaxSize]; /**/         struct schoolstruct *next;      }SCH;         int nsc,msp,wsp;      int ntsp;      int i,j;      int overgame;      int serial,range;      int n;      SCH *head,*pfirst,*psecond;      int *phead=NULL,*pafirst=NULL,*pasecond=NULL;     void create();         void input ()     {         char answer;          head = (SCH *)malloc(sizeof(SCH)); /**/         head->next = NULL;         pfirst = head;          answer = 'y';         while ( answer == 'y' )         {         Is_Game_DoMain:         printf("\nGET Top 5 when odd\nGET Top 3 when even");         printf("\n輸入運動項目序號 (x<=%d):",ntsp);         scanf("%d",pafirst);         overgame = *pafirst;         if ( pafirst != phead )         {             for ( pasecond = phead ; pasecond < pafirst ; pasecond ++ )             {                 if ( overgame == *pasecond )                 {                     printf("\n這個項目已經存在請選擇其他的數字\n");                     goto Is_Game_DoMain;                 }             }         }         pafirst = pafirst + 1;         if ( overgame > ntsp )         {             printf("\n項目不存在");             printf("\n請重新輸入");             goto Is_Game_DoMain;         }         switch ( overgame%2 )         {         case 0: n = 3;break;         case 1: n = 5;break;         }         for ( i = 1 ; i <= n ; i++ )         {         Is_Serial_DoMain:         printf("\n輸入序號 of the NO.%d (0<x<=%d): ",i,nsc);                 scanf("%d",&serial);         if ( serial > nsc )          {             printf("\n超過學校數目,請重新輸入");             goto Is_Serial_DoMain;         }         if ( head->next == NULL )          {             create();         }         psecond = head->next ;          while ( psecond != NULL )          {             if ( psecond->serial == serial )             {                 pfirst = psecond;                 pfirst->count = pfirst->count + 1;                 goto Store_Data;             }             else             {                 psecond = psecond->next;             }         }         create();         Store_Data:                 pfirst->athlete[pfirst->count].item = overgame;         pfirst->athlete[pfirst->count].range = i;         pfirst->serial = serial;         printf("Input name:) : ");                 scanf("%s",pfirst->athlete[pfirst->count].name);         }         printf("\n繼續輸入運動項目(y&n)?");         answer = getchar();         printf("\n");         }     }         void calculate() /**/     {         pfirst = head->next;         while ( pfirst->next != NULL )         {             for (i=1;i<=pfirst->count;i++)             {                 if ( pfirst->athlete[i].item % 2 == 0 )                  {                     switch (pfirst->athlete[i].range)                     {                     case 1:pfirst->athlete[i].score = 5;break;                     case 2:pfirst->athlete[i].score = 3;break;                     case 3:pfirst->athlete[i].score = 2;break;                     }                 }                 else                  {                     switch (pfirst->athlete[i].range)                     {                     case 1:pfirst->athlete[i].score = 7;break;                     case 2:pfirst->athlete[i].score = 5;break;                     case 3:pfirst->athlete[i].score = 3;break;                     case 4:pfirst->athlete[i].score = 2;break;                     case 5:pfirst->athlete[i].score = 1;break;                     }                 }                 if ( pfirst->athlete[i].item <=msp )                  {                     pfirst->menscore = pfirst->menscore + pfirst->athlete[i].score;                 }                 else                  {                     pfirst->womenscore = pfirst->womenscore + pfirst->athlete[i].score;                 }             }             pfirst->totalscore = pfirst->menscore + pfirst->womenscore;             pfirst = pfirst->next;         }     }         void output()     {         pfirst = head->next;         psecond = head->next;         while ( pfirst->next != NULL )          {             // clrscr();              printf("\n第%d號學校的結果成績:",pfirst->serial);             printf("\n\n項目的數目\t學校的名字\t分數");             for (i=1;i<=ntsp;i++)              {                 for (j=1;j<=pfirst->count;j++)                  {                     if ( pfirst->athlete[j].item == i )                     {                                                                         printf("\n %d\t\t\t\t\t\t%s\n %d",i,pfirst->athlete[j].name,pfirst->athlete[j].score);break;                                             }                 }             }             printf("\n\n\n\t\t\t\t\t\t按任意建 進入下一頁");             getchar();             pfirst = pfirst->next;         }     //  clrscr();          printf("\n運動會結果:\n\n學校編號\t男運動員成績\t女運動員成績\t總分");         pfirst = head->next;         while ( pfirst->next != NULL )         {             printf("\n %d\t\t %d\t\t %d\t\t %d",pfirst->serial,pfirst->menscore,pfirst->womenscore,pfirst->totalscore);             pfirst = pfirst->next;         }         printf("\n\n\n\t\t\t\t\t\t\t按任意建結束");         getchar();     }         void create()     {                 pfirst = (struct schoolstruct *)malloc(sizeof(struct schoolstruct));         pfirst->next = head->next ;         head->next = pfirst ;                 pfirst->count = 1;         pfirst->menscore = 0;         pfirst->womenscore = 0;         pfirst->totalscore = 0;     }     void Save()     {FILE *fp;     if((fp = fopen("school.dat","wb"))==NULL)     {printf("can't open school.dat\n");     fclose(fp);     return;     }     fwrite(pfirst,sizeof(SCH),10,fp);     fclose(fp);     printf("文件已經成功保存\n");     }         void main()     {         system("cls");         printf("\n\t\t\t 運動會分數統計\n");         printf("輸入學校數目 (x>= 5):");         scanf("%d",&nsc);          printf("輸入男選手的項目(x<=20):");         scanf("%d",&msp);          printf("輸入女選手項目(<=20):");         scanf("%d",&wsp);          ntsp = msp + wsp;                  phead = (int *)calloc(ntsp,sizeof(int));         pafirst = phead;         pasecond = phead;         input();         calculate();          output();         Save();     }             

    標簽: 源代碼

    上傳時間: 2016-12-28

    上傳用戶:150501

  • 學生管理啊

    #include <iostream.h> #include <string.h> #include <iomanip.h> #include "Stud.h" Stud::Stud(){} char *Stud::getno()              //獲取學號 { return no; } char *Stud::getname()            //獲取姓名 { return name; } char *Stud::getsex()             //獲取性別 { return sex; } char *Stud::getminzu()           //獲取民族 { return minzu; } char *Stud::getaddress()         //獲取出生地 { return address; } char *Stud::getbirth()           //獲取出生年月 { return birth; } int Stud::gettag()               //獲取姓名 { return tag; } void Stud::changeno(char n[])                 //設置學號 { strcpy(no,n); } void Stud::changename(char na[])              //設置姓名 { strcpy(name,na); } void Stud::changesex(char s[])                //設置性別 { strcpy(sex,s); } void Stud::changeminzu(char m[])               //設置民族 { strcpy(minzu,m); } void Stud::changeaddress(char a[])             //設置出生地 { strcpy(address,a); } void Stud::changebirth(char b[])               //設置出生年月 { strcpy(birth,b); } void Stud::addstudent(char *rn,char *rna)      //增加學生 {     strcpy(no,rn); strcpy(name,rna); } void Stud::addstudent(char *rn,char *rna,char *rs,char *rm,char *ra,char *rb)    //增加學生 { tag=0; strcpy(no,rn); strcpy(name,rna); strcpy(sex,rs); strcpy(minzu,rm); strcpy(address,ra); strcpy(birth,rb); } void Stud::delstud()                         //設置刪除標記 { tag=1; } void Stud::disp()                            //輸出學生信息 { cout<<setw(15)<<no<<setw(10)<<name<<setw(10)<<sex<<setw(10)<<minzu<<setw(10)<<address<<setw(10)<<birth<<endl; } void Stud::display()                         //輸出學生信息 {     cout<<setw(15)<<no<<setw(10)<<name; }

    標簽: 學生

    上傳時間: 2016-12-29

    上傳用戶:767483511

主站蜘蛛池模板: 嘉祥县| 宝鸡市| 普格县| 澄江县| 额敏县| 惠来县| 阿鲁科尔沁旗| 逊克县| 耒阳市| 涞水县| 垣曲县| 宝坻区| 阿拉尔市| 屏东市| 贵阳市| 宁明县| 青龙| 陆丰市| 江津市| 东阳市| 治县。| 察隅县| 平顺县| 天台县| 宜州市| 黎平县| 塔城市| 灵璧县| 普陀区| 镇沅| 定州市| 三穗县| 新乡市| 松滋市| 富川| 正阳县| 保定市| 衡水市| 永仁县| 赞皇县| 洪雅县|