Created
November 9, 2015 23:49
-
-
Save N0taN3rd/598a74e0cb4c65102232 to your computer and use it in GitHub Desktop.
This file contains 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 <string> | |
#include<fstream> | |
#include <vector> | |
using namespace std ; | |
struct node{ | |
int value; | |
node* next; | |
node(int val) { | |
value = val; | |
next = nullptr; | |
} | |
}; | |
int main() | |
{ | |
node* head = new node(0), *cur = head, *temp; | |
int c = 0; | |
while(c < 10){ | |
temp = new node(++c); | |
cur->next = temp; | |
cur = temp; | |
} | |
node* travel = head; | |
node* prev; | |
int move = 2; | |
int i = 0; | |
cout<<"first move"<<endl; | |
while(i < move){ | |
cout<<travel->value<<"->"; | |
prev = travel; | |
travel = travel->next; | |
i++; | |
delete prev; | |
} | |
cout<<endl; | |
move = 3; | |
i = 0; | |
cout<<"second move"<<endl; | |
while(i < move){ | |
cout<<travel->value<<"->"; | |
prev = travel; | |
travel = travel->next; | |
i++; | |
delete prev; | |
} | |
cout<<"\nrest"<<endl; | |
while(travel != nullptr){ | |
cout<<travel->value<<"->"; | |
prev = travel; | |
travel = travel->next; | |
delete prev; | |
} | |
cout<<"null"<<endl; | |
ifstream in("board.txt"); | |
vector<vector<char>> board; | |
int num = 0; | |
string line; | |
int lineCount = 0; | |
while(getline(in,line)){ | |
cout<<"At line "<<lineCount<<" "<<line<<endl; | |
vector<char> boardPart; | |
for(int i = 0; i < line.length(); ++i) { | |
boardPart.push_back(line[i]); | |
} | |
board.push_back(boardPart); | |
lineCount++; | |
} | |
cout<<endl; | |
for(int i = 0; i < board.size(); ++i){ | |
int len = board[i].size(); | |
for(int j = 0; j < len; ++j){ | |
cout<<"[i="<<i<<" j="<<j<<" space="<<board[i][j]<<"] "<<endl; | |
} | |
cout<<endl; | |
} | |
for(vector<char> bp : board){ | |
for(char c : bp){ | |
cout<<c<<" "; | |
} | |
cout<<endl; | |
} | |
board[12][10] = 'G'; | |
board[10][10] = '6'; | |
cout<<endl; | |
for(vector<char> bp : board){ | |
for(char c : bp){ | |
cout<<c<<" "; | |
} | |
cout<<endl; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment