C言語

アニールネットワーク

アニールネットワーク #include<stdio.h> #include<math.h> #include<set> #include<map> #include<vector> #include<sstream> #include<fstream> #include<iostream> #include<string.h> #include<stdlib.h> int main(){ using namespace std; FILE *fp; std::string index; std::string str; std::string str2; std::map</stdlib.h></string.h></iostream></fstream></sstream></vector></map></set></math.h></stdio.h>

C++でネットワークの次数を求める

C++でネットワークの次数を求める test.net 1 3 2 3 4 5 2 1 #include<stdio.h> #include<iostream> #include<map> #include<string> #include<fstream> #include<vector> #include<set> int main(){ using namespace std; FILE *fp; std::string index; std::string value; std::string str; string str2; std::vec</set></vector></fstream></string></map></iostream></stdio.h>…

C++でスペース区切りのデータを連想配列に詰め込む

test.dat 1 2 1 3 1 5 3 5 2 4 #include<stdio.h> #include<iostream> #include<map> #include<string> #include<fstream> int main(){ using namespace std; FILE *fp; std::string index; std::string value; std::string str; char* str2; std::map<std::string,std::string> data; std::ifstream ifs("test.dat"); whil…</std::string,std::string></fstream></string></map></iostream></stdio.h>

c言語でカンマ区切りの文章を読む

c言語でカンマ区切りの文章を読む http://simd.jugem.jp/?eid=49 http://networkprogramming.blog18.fc2.com/blog-entry-89.htmlstrtok関数で空白で分ける。 strtok関数は、 strtok(文字列,区切り文字)の仕様。 一回目はstrok(文字列, 区切り文字)で呼ぶ。 …

C++言語で連想配列風。

C++言語で連想配列風。 map型を使って楽する。 #include <stdio.h> #include <string> #include <map> #include <iostream> int main(){ using namespace std; std::map<std::string,std::string> data; data["a"]="AA"; data["b"]="BB"; data["d"]="CC"; data["e"]="EE"; cout << data["d"] <<"\n"; return 0; }</std::string,std::string></iostream></map></string></stdio.h>

 構造体と構造体ポインタ

構造体でのキューの例。 (1)構造体の定義 (2)構造体宣言 (3)構造体ポインタ宣言 (4)アドレスを渡す。 (5)使うという順番。 struct node{ double value; struct node *next; }; int main(){ struct node fist; struct node *nodeA nodeA=&fist…

 gdb の使い方

gdb はgnuのデバックのためのソフト。 例えば、セグメンテーションフォールトの位置が簡単に調べられる。 基本編(1)特殊なオプション-gをつけてコンパイル。 gcc -O2 -g sample.c -o test.out (2)gdbを実行 gdb test.out (3)gdbの中でrunと打ち込む。 (gdb) …