Skip to content

Instantly share code, notes, and snippets.

@N0taN3rd
Created November 9, 2015 23:49
Show Gist options
  • Save N0taN3rd/598a74e0cb4c65102232 to your computer and use it in GitHub Desktop.
Save N0taN3rd/598a74e0cb4c65102232 to your computer and use it in GitHub Desktop.
#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