-
Notifications
You must be signed in to change notification settings - Fork 0
HamiltonB program #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
Crackhoff
wants to merge
3
commits into
master
Choose a base branch
from
beta
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,3 +34,6 @@ | |
| # Private data | ||
| UsersData.txt | ||
| CircleOfLife.txt | ||
| *.layout | ||
| *.depend | ||
|
|
||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| <?xml version="1.0" encoding="UTF-8" standalone="yes" ?> | ||
| <CodeBlocks_project_file> | ||
| <FileVersion major="1" minor="6" /> | ||
| <Project> | ||
| <Option title="Hamilton" /> | ||
| <Option pch_mode="2" /> | ||
| <Option compiler="gcc" /> | ||
| <Build> | ||
| <Target title="Debug"> | ||
| <Option output="bin/Debug/Hamilton" prefix_auto="1" extension_auto="1" /> | ||
| <Option object_output="obj/Debug/" /> | ||
| <Option type="1" /> | ||
| <Option compiler="gcc" /> | ||
| <Compiler> | ||
| <Add option="-g" /> | ||
| </Compiler> | ||
| </Target> | ||
| <Target title="Release"> | ||
| <Option output="bin/Release/Hamilton" prefix_auto="1" extension_auto="1" /> | ||
| <Option object_output="obj/Release/" /> | ||
| <Option type="1" /> | ||
| <Option compiler="gcc" /> | ||
| <Compiler> | ||
| <Add option="-O2" /> | ||
| </Compiler> | ||
| <Linker> | ||
| <Add option="-s" /> | ||
| </Linker> | ||
| </Target> | ||
| </Build> | ||
| <Compiler> | ||
| <Add option="-Wall" /> | ||
| <Add option="-fexceptions" /> | ||
| </Compiler> | ||
| <Unit filename="main.cpp" /> | ||
| <Extensions> | ||
| <code_completion /> | ||
| <envvars /> | ||
| <debugger /> | ||
| <lib_finder disable_auto="1" /> | ||
| </Extensions> | ||
| </Project> | ||
| </CodeBlocks_project_file> |
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| <?xml version="1.0" encoding="UTF-8" standalone="yes" ?> | ||
| <CodeBlocks_project_file> | ||
| <FileVersion major="1" minor="6" /> | ||
| <Project> | ||
| <Option title="HamiltonB" /> | ||
| <Option pch_mode="2" /> | ||
| <Option compiler="gcc" /> | ||
| <Build> | ||
| <Target title="Debug"> | ||
| <Option output="bin/Debug/HamiltonB" prefix_auto="1" extension_auto="1" /> | ||
| <Option working_dir="HamiltonB/bin" /> | ||
| <Option object_output="obj/Debug/" /> | ||
| <Option type="1" /> | ||
| <Option compiler="gcc" /> | ||
| <Compiler> | ||
| <Add option="-g" /> | ||
| </Compiler> | ||
| </Target> | ||
| <Target title="Release"> | ||
| <Option output="bin/Release/HamiltonB" prefix_auto="1" extension_auto="1" /> | ||
| <Option object_output="obj/Release/" /> | ||
| <Option type="1" /> | ||
| <Option compiler="gcc" /> | ||
| <Compiler> | ||
| <Add option="-O2" /> | ||
| </Compiler> | ||
| <Linker> | ||
| <Add option="-s" /> | ||
| </Linker> | ||
| </Target> | ||
| </Build> | ||
| <Compiler> | ||
| <Add option="-Wall" /> | ||
| <Add option="-fexceptions" /> | ||
| </Compiler> | ||
| <Unit filename="main.cpp" /> | ||
| <Extensions> | ||
| <code_completion /> | ||
| <envvars /> | ||
| <debugger> | ||
| <search_path add="D:\dla marcinka\Hamilton\" /> | ||
| </debugger> | ||
| <lib_finder disable_auto="1" /> | ||
| </Extensions> | ||
| </Project> | ||
| </CodeBlocks_project_file> |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| #include <iostream> | ||
| #include <fstream> | ||
| #include <cstdlib> | ||
|
|
||
| using namespace std; | ||
| int n=0; | ||
| int main() | ||
| { | ||
| system("echo %cd%"); | ||
| int *numbers=NULL; | ||
| string *people=NULL,*gamelist=NULL; | ||
| string message,line; | ||
| ifstream file; | ||
| file.open ("UsersData.txt"); | ||
| if (file.is_open()) | ||
Nircek marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| while(getline(file,line)) | ||
| ++n; | ||
| people = new string[n]; | ||
| file.clear(); | ||
| file.seekg(0); | ||
| for(int i=0;getline(file,line);++i) | ||
| people[i] = line; //koniec operowania na danych z tego pliku | ||
| gamelist = new string[n]; | ||
| file.clear(); | ||
| file.seekg(0); | ||
| for(int i=0;getline(file,line);++i) | ||
| { | ||
| cout << line << '\n'; | ||
| gamelist[i] = line; | ||
| } | ||
| } | ||
| ifstream nextfile; | ||
| nextfile.open ("CircleOfLife.txt"); | ||
| if (nextfile.is_open()) | ||
| { | ||
| numbers = new int[n]; | ||
| for(int i=0;i<n;++i) | ||
| nextfile >> numbers[i]; | ||
| } | ||
| getline(cin, message); | ||
| cout << message; | ||
| if (message == "display") | ||
| for(int i=0;i<n;++i) | ||
| cout << gamelist[numbers[i]] << '\n'; | ||
| else { | ||
| for(int i=0;i<n;++i) | ||
| if (message == gamelist[i]) | ||
| { | ||
| for(;i<n;++i) | ||
| { | ||
| i = i%n; | ||
| gamelist[i]=gamelist[i+1]; | ||
| } | ||
| --n; | ||
| cout << n; | ||
| cout << "Deleted from the circle" << '\n'; | ||
| for(int k=0;k<n;++k) | ||
| cout << gamelist[numbers[k]] << '\n'; | ||
| } | ||
| } | ||
| return 0; | ||
| } | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,136 @@ | ||
| #include <iostream> | ||
| #include <fstream> | ||
| #include <string> | ||
| #include <ctime> | ||
| #include <cstdlib> | ||
|
|
||
| using namespace std; | ||
| string decision; | ||
| int main() | ||
| { | ||
| cout << "co chcesz zrobi�"; | ||
| cin >> decision; | ||
| if (decision == "HamiltonA"); | ||
| HamiltonA() | ||
| else if decision == "HamiltonB"; | ||
| HamiltonB; | ||
| else cout << "try again"; | ||
| } | ||
|
|
||
| HamiltonA() | ||
| { | ||
| using namespace std; | ||
|
|
||
| bool isinarr(int x, int arr[], int n) | ||
| { | ||
| for(int i=0;i<n;++i) | ||
| if (x==arr[i]) | ||
| return true; | ||
| return false; | ||
| } | ||
|
|
||
| int main() | ||
| { | ||
| srand(time(NULL)); | ||
| string *lista=NULL; | ||
| int *circle=NULL; | ||
| int n=0; | ||
| string line; | ||
| ifstream file; | ||
| file.open("UsersData.txt",ios::in); | ||
| if(file.is_open()) | ||
| { | ||
| while(getline(file,line)) | ||
| ++n; | ||
| file.clear(); | ||
| file.seekg(0, ios::beg); | ||
| cout << n << '\n'; | ||
| lista = new string[n]; | ||
| circle = new int[n]; | ||
| for(int i=0;i<n;++i) | ||
| circle[i]=-1; | ||
| for(int i=0;getline(file,line);i++) | ||
| lista[i] = line; | ||
| file.close(); | ||
| } | ||
| else cout << "Unable to open the file"; | ||
| for(int i=0;i<n;++i) | ||
| { | ||
| int k; | ||
| do k=rand()%n; | ||
| while( isinarr(k, circle, n)); | ||
| circle[i]=k; | ||
| cout << k << '\n'; | ||
| } | ||
| ofstream finish; | ||
| finish.open ("CircleOfLife.txt"); | ||
| for(int i=0;i<n;++i) | ||
| { | ||
| finish << circle[i] << '\n'; | ||
| } | ||
| delete[] lista; | ||
| return 0; | ||
| } | ||
| } | ||
| HamiltonB() | ||
| { | ||
| using namespace std; | ||
| int n=0; | ||
| int main() | ||
| { | ||
| system("echo %cd%"); | ||
| int *numbers=NULL; | ||
| string *people=NULL,*gamelist=NULL; | ||
| string message,line; | ||
| ifstream file; | ||
| file.open ("UsersData.txt"); | ||
| if (file.is_open()) | ||
| { | ||
| while(getline(file,line)) | ||
| ++n; | ||
| people = new string[n]; | ||
| file.clear(); | ||
| file.seekg(0); | ||
| for(int i=0;getline(file,line);++i) | ||
| people[i] = line; //koniec operowania na danych z tego pliku | ||
| gamelist = new string[n]; | ||
| file.clear(); | ||
| file.seekg(0); | ||
| for(int i=0;getline(file,line);++i) | ||
| { | ||
| cout << line << '\n'; | ||
| gamelist[i] = line; | ||
| } | ||
| } | ||
| ifstream nextfile; | ||
| nextfile.open ("CircleOfLife.txt"); | ||
| if (nextfile.is_open()) | ||
| { | ||
| numbers = new int[n]; | ||
| for(int i=0;i<n;++i) | ||
| nextfile >> numbers[i]; | ||
| } | ||
| getline(cin, message); | ||
| cout << message; | ||
| if (message == "display") | ||
| for(int i=0;i<n;++i) | ||
| cout << gamelist[numbers[i]] << '\n'; | ||
| else { | ||
| for(int i=0;i<n;++i) | ||
| if (message == gamelist[i]) | ||
| { | ||
| for(;i<n;++i) | ||
| { | ||
| i = i%n; | ||
| gamelist[i]=gamelist[i+1]; | ||
| } | ||
| --n; | ||
| cout << n; | ||
| cout << "Deleted from the circle" << '\n'; | ||
| for(int k=0;k<n;++k) | ||
| cout << gamelist[numbers[k]] << '\n'; | ||
| } | ||
| } | ||
| return 0; | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*.dependis here butHamiltonA/HamiltonA.dependis tracked