Created
August 24, 2013 11:48
-
-
Save hirosof/6327677 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <cstdio> | |
#include "CHSLinearList.hpp" | |
using namespace std; | |
struct Mydata | |
{ | |
char Text[100]; | |
int number; | |
}; | |
int main(void){ | |
CHSLinearList<Mydata> list; | |
int nums = 16; | |
//データ追加 | |
for (int i = 0; i < nums; i++){ | |
Mydata data; | |
sprintf_s(data.Text , "Mydata:%d" , i); | |
data.number = 1000 + i; | |
list << data; | |
} | |
//偶数番目に追加したデータ削除 | |
nums = (int)list; | |
for (int i = 0; i < nums ; i+=2){ | |
list.Delete(i , true); | |
} | |
//データ2つ追加 | |
for (int i = 0; i < 2; i++){ | |
Mydata data; | |
sprintf_s(data.Text , "Mydata(add):%d" , i); | |
data.number = 2000 + i; | |
list << data; | |
} | |
//全て表示する | |
nums = (int)list; | |
for (int i = 0; i < nums; i++){ | |
cout << "[" << list(i).number << "] : " <<list(i).Text <<endl; | |
} | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment