finished
This commit is contained in:
parent
3ab836d91c
commit
86f918a739
135
.clang-format
Normal file
135
.clang-format
Normal file
@ -0,0 +1,135 @@
|
||||
---
|
||||
Language: Cpp
|
||||
AccessModifierOffset: -4
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignConsecutiveMacros: false
|
||||
AlignConsecutiveAssignments: false
|
||||
AlignConsecutiveDeclarations: false
|
||||
AlignEscapedNewlines: Right
|
||||
AlignOperands: true
|
||||
AlignTrailingComments: true
|
||||
AllowAllArgumentsOnNextLine: false
|
||||
AllowAllConstructorInitializersOnNextLine: true
|
||||
AllowAllParametersOfDeclarationOnNextLine: false
|
||||
AllowShortBlocksOnASingleLine: Never
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: None
|
||||
AllowShortLambdasOnASingleLine: All
|
||||
AllowShortIfStatementsOnASingleLine: Never
|
||||
AllowShortLoopsOnASingleLine: false
|
||||
AlwaysBreakAfterDefinitionReturnType: None
|
||||
AlwaysBreakAfterReturnType: None
|
||||
AlwaysBreakBeforeMultilineStrings: false
|
||||
AlwaysBreakTemplateDeclarations: Yes
|
||||
BinPackArguments: false
|
||||
BinPackParameters: false
|
||||
BraceWrapping:
|
||||
AfterCaseLabel: true
|
||||
AfterClass: true
|
||||
AfterControlStatement: true
|
||||
AfterEnum: true
|
||||
AfterFunction: true
|
||||
AfterNamespace: true
|
||||
AfterObjCDeclaration: true
|
||||
AfterStruct: true
|
||||
AfterUnion: true
|
||||
AfterExternBlock: true
|
||||
BeforeCatch: true
|
||||
BeforeElse: true
|
||||
IndentBraces: false
|
||||
SplitEmptyFunction: true
|
||||
SplitEmptyRecord: true
|
||||
SplitEmptyNamespace: true
|
||||
BreakBeforeBinaryOperators: None
|
||||
BreakBeforeBraces: Custom
|
||||
BreakBeforeInheritanceComma: false
|
||||
BreakInheritanceList: BeforeColon
|
||||
BreakBeforeTernaryOperators: true
|
||||
BreakConstructorInitializersBeforeComma: false
|
||||
BreakConstructorInitializers: BeforeColon
|
||||
BreakAfterJavaFieldAnnotations: false
|
||||
BreakStringLiterals: true
|
||||
ColumnLimit: 120
|
||||
CommentPragmas: '^ IWYU pragma:'
|
||||
CompactNamespaces: false
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: false
|
||||
ConstructorInitializerIndentWidth: 4
|
||||
ContinuationIndentWidth: 4
|
||||
Cpp11BracedListStyle: true
|
||||
DeriveLineEnding: true
|
||||
DerivePointerAlignment: false
|
||||
DisableFormat: false
|
||||
ExperimentalAutoDetectBinPacking: false
|
||||
FixNamespaceComments: true
|
||||
ForEachMacros:
|
||||
- foreach
|
||||
- Q_FOREACH
|
||||
- BOOST_FOREACH
|
||||
IncludeBlocks: Preserve
|
||||
IncludeCategories:
|
||||
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
|
||||
Priority: 2
|
||||
SortPriority: 0
|
||||
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
|
||||
Priority: 3
|
||||
SortPriority: 0
|
||||
- Regex: '.*'
|
||||
Priority: 1
|
||||
SortPriority: 0
|
||||
IncludeIsMainRegex: '(Test)?$'
|
||||
IncludeIsMainSourceRegex: ''
|
||||
IndentCaseLabels: false
|
||||
IndentGotoLabels: true
|
||||
IndentPPDirectives: None
|
||||
IndentWidth: 4
|
||||
IndentWrappedFunctionNames: false
|
||||
JavaScriptQuotes: Leave
|
||||
JavaScriptWrapImports: true
|
||||
KeepEmptyLinesAtTheStartOfBlocks: true
|
||||
MacroBlockBegin: ''
|
||||
MacroBlockEnd: ''
|
||||
MaxEmptyLinesToKeep: 2
|
||||
NamespaceIndentation: None
|
||||
ObjCBinPackProtocolList: Auto
|
||||
ObjCBlockIndentWidth: 2
|
||||
ObjCSpaceAfterProperty: false
|
||||
ObjCSpaceBeforeProtocolList: true
|
||||
PenaltyBreakAssignment: 2
|
||||
PenaltyBreakBeforeFirstCallParameter: 19
|
||||
PenaltyBreakComment: 300
|
||||
PenaltyBreakFirstLessLess: 120
|
||||
PenaltyBreakString: 1000
|
||||
PenaltyBreakTemplateDeclaration: 10
|
||||
PenaltyExcessCharacter: 1000000
|
||||
PenaltyReturnTypeOnItsOwnLine: 1000
|
||||
PointerAlignment: Right
|
||||
ReflowComments: false
|
||||
SortIncludes: true
|
||||
SortUsingDeclarations: true
|
||||
SpaceAfterCStyleCast: false
|
||||
SpaceAfterLogicalNot: false
|
||||
SpaceAfterTemplateKeyword: true
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
SpaceBeforeCpp11BracedList: false
|
||||
SpaceBeforeCtorInitializerColon: true
|
||||
SpaceBeforeInheritanceColon: true
|
||||
SpaceBeforeParens: ControlStatements
|
||||
SpaceBeforeRangeBasedForLoopColon: true
|
||||
SpaceInEmptyBlock: false
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesBeforeTrailingComments: 1
|
||||
SpacesInAngles: false
|
||||
SpacesInConditionalStatement: false
|
||||
SpacesInContainerLiterals: true
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpacesInParentheses: false
|
||||
SpacesInSquareBrackets: false
|
||||
SpaceBeforeSquareBrackets: false
|
||||
Standard: Latest
|
||||
StatementMacros:
|
||||
- Q_UNUSED
|
||||
- QT_REQUIRE_VERSION
|
||||
TabWidth: 4
|
||||
UseCRLF: false
|
||||
UseTab: Never
|
||||
...
|
9
.clang-tidy
Normal file
9
.clang-tidy
Normal file
@ -0,0 +1,9 @@
|
||||
---
|
||||
Checks: 'clang-analyzer-*,cppcoreguidelines-*,modernize-*,bugprone-*,performance-*,readability-*,readability-non-const-parameter,misc-const-correctness,misc-use-anonymous-namespace,google-explicit-constructor,-modernize-use-trailing-return-type,-bugprone-exception-escape,-cppcoreguidelines-pro-bounds-constant-array-index,-cppcoreguidelines-avoid-magic-numbers,-bugprone-easily-swappable-parameters,-cppcoreguidelines-non-private-member-variables-in-classes'
|
||||
WarningsAsErrors: ''
|
||||
HeaderFilterRegex: ''
|
||||
CheckOptions:
|
||||
- key: readability-magic-numbers.IgnoredFloatingPointValues
|
||||
value: '0.0;1.0;100.0;'
|
||||
- key: readability-magic-numbers.IgnoredIntegerValues
|
||||
value: '0;1;2;3;4;5;6;7;8;9;'
|
17
.editorconfig
Normal file
17
.editorconfig
Normal file
@ -0,0 +1,17 @@
|
||||
# EditorConfig is awesome: http://EditorConfig.org
|
||||
|
||||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
end_of_line = lf
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
[Makefile]
|
||||
indent_style = tab
|
||||
trim_trailing_whitespace = false
|
11
.gitattributes
vendored
Normal file
11
.gitattributes
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
# Set the default behavior for all files.
|
||||
* text=auto eol=lf
|
||||
|
||||
# Normalized and converts to native line endings on checkout.
|
||||
*.c text
|
||||
*.cc text
|
||||
*.cxx
|
||||
*.cpp text
|
||||
*.h text
|
||||
*.hxx text
|
||||
*.hpp text
|
146
.gitignore
vendored
Normal file
146
.gitignore
vendored
Normal file
@ -0,0 +1,146 @@
|
||||
################################
|
||||
########### FILES ############
|
||||
################################
|
||||
*.pptx
|
||||
|
||||
################################
|
||||
########### FOLDERS ############
|
||||
################################
|
||||
build/
|
||||
build-*/
|
||||
html/
|
||||
|
||||
################################
|
||||
############ C/C++ #############
|
||||
################################
|
||||
# Prerequisites
|
||||
*.d
|
||||
# Compiled Object files
|
||||
*.slo
|
||||
*.lo
|
||||
*.o
|
||||
*.obj
|
||||
*.ko
|
||||
*.elf
|
||||
# Precompiled Headers
|
||||
*.gch
|
||||
*.pch
|
||||
# Compiled Dynamic libraries
|
||||
*.so
|
||||
*.dylib
|
||||
*.dll
|
||||
# Fortran module files
|
||||
*.mod
|
||||
*.smod
|
||||
# Compiled Static libraries
|
||||
*.lai
|
||||
*.la
|
||||
*.a
|
||||
*.lib
|
||||
# Executables
|
||||
*.i*86
|
||||
*.x86_64
|
||||
*.hex
|
||||
*.app
|
||||
*.stackdump
|
||||
*.exe
|
||||
*.out
|
||||
# Linker output
|
||||
*.ilk
|
||||
*.map
|
||||
*.exp
|
||||
# Debug files
|
||||
*.dSYM/
|
||||
*.su
|
||||
*.idb
|
||||
*.pdb
|
||||
|
||||
################################
|
||||
########### VS CODE ############
|
||||
################################
|
||||
.vscode/settings.json
|
||||
.vscode/c_cpp_properties.json
|
||||
*.code-workspace
|
||||
.history
|
||||
|
||||
################################
|
||||
########### VS ############
|
||||
################################
|
||||
|
||||
# User-specific files
|
||||
*.rsuser
|
||||
*.suo
|
||||
*.user
|
||||
*.userosscache
|
||||
*.sln.docstates
|
||||
|
||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||
*.userprefs
|
||||
|
||||
# Mono auto generated files
|
||||
mono_crash.*
|
||||
|
||||
# Build results
|
||||
[Dd]ebug/
|
||||
[Dd]ebugPublic/
|
||||
[Rr]elease/
|
||||
[Rr]eleases/
|
||||
x64/
|
||||
x86/
|
||||
[Ww][Ii][Nn]32/
|
||||
[Aa][Rr][Mm]/
|
||||
[Aa][Rr][Mm]64/
|
||||
bld/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
[Ll]og/
|
||||
[Ll]ogs/
|
||||
|
||||
# Files built by Visual Studio
|
||||
*_i.c
|
||||
*_p.c
|
||||
*_h.h
|
||||
*.meta
|
||||
*.iobj
|
||||
*.ipdb
|
||||
*.pgc
|
||||
*.pgd
|
||||
*.rsp
|
||||
*.sbr
|
||||
*.tlb
|
||||
*.tli
|
||||
*.tlh
|
||||
*.tmp
|
||||
*.tmp_proj
|
||||
*_wpftmp.csproj
|
||||
*.log
|
||||
*.tlog
|
||||
*.vspscc
|
||||
*.vssscc
|
||||
.builds
|
||||
*.pidb
|
||||
*.svclog
|
||||
*.scc
|
||||
|
||||
# Chutzpah Test files
|
||||
_Chutzpah*
|
||||
|
||||
# Visual C++ cache files
|
||||
ipch/
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opendb
|
||||
*.opensdf
|
||||
*.sdf
|
||||
*.cachefile
|
||||
*.VC.db
|
||||
*.VC.VC.opendb
|
||||
|
||||
# Visual Studio profiler
|
||||
*.psess
|
||||
*.vsp
|
||||
*.vspx
|
||||
*.sap
|
||||
|
||||
# Visual Studio Trace Files
|
||||
*.e2e
|
4
.vscode/c_cpp_properties.json
vendored
4
.vscode/c_cpp_properties.json
vendored
@ -6,8 +6,8 @@
|
||||
"${workspaceFolder}/**"
|
||||
],
|
||||
"compilerPath": "/usr/bin/gcc",
|
||||
"cStandard": "${default}",
|
||||
"cppStandard": "c++23",
|
||||
"cStandard": "c11",
|
||||
"cppStandard": "c++20",
|
||||
"intelliSenseMode": "linux-gcc-x64",
|
||||
"compilerArgs": [
|
||||
""
|
||||
|
143
.vscode/settings.json
vendored
143
.vscode/settings.json
vendored
@ -1,10 +1,142 @@
|
||||
{
|
||||
"editor.tabSize": 4,
|
||||
"editor.rulers": [
|
||||
120
|
||||
],
|
||||
"editor.renderWhitespace": "trailing",
|
||||
"editor.suggestSelection": "first",
|
||||
"editor.cursorSmoothCaretAnimation": "on",
|
||||
"terminal.integrated.defaultProfile.windows": "Command Prompt",
|
||||
"explorer.compactFolders": false,
|
||||
"explorer.confirmDragAndDrop": false,
|
||||
"explorer.confirmDelete": false,
|
||||
"explorer.copyRelativePathSeparator": "/",
|
||||
"files.autoSave": "onFocusChange",
|
||||
"files.associations": {
|
||||
".clang*": "yaml",
|
||||
"*.hpp.in": "cpp",
|
||||
"*.in": "cpp"
|
||||
},
|
||||
"files.insertFinalNewline": true,
|
||||
"files.trimFinalNewlines": true,
|
||||
"files.trimTrailingWhitespace": true,
|
||||
"workbench.editorAssociations": {
|
||||
"*.md": "vscode.markdown.preview.editor",
|
||||
"*.svg": "svgPreviewer.customEditor"
|
||||
},
|
||||
"git.enableSmartCommit": true,
|
||||
"git.autofetch": true,
|
||||
"git.confirmSync": false,
|
||||
"git.openRepositoryInParentFolders": "always",
|
||||
"markdown.validate.enabled": true,
|
||||
"[markdown]": {
|
||||
"files.trimTrailingWhitespace": false,
|
||||
"editor.formatOnSave": false,
|
||||
"editor.defaultFormatter": "yzhang.markdown-all-in-one",
|
||||
"editor.wordWrap": "wordWrapColumn",
|
||||
"editor.wordWrapColumn": 120
|
||||
},
|
||||
"[yaml]": {
|
||||
"editor.formatOnSave": false,
|
||||
"editor.defaultFormatter": "redhat.vscode-yaml",
|
||||
"editor.wordWrap": "wordWrapColumn",
|
||||
"editor.wordWrapColumn": 120
|
||||
},
|
||||
"[plaintext]": {
|
||||
"editor.wordWrap": "wordWrapColumn",
|
||||
"editor.wordWrapColumn": 120
|
||||
},
|
||||
"[toml]": {
|
||||
"editor.wordWrap": "wordWrapColumn",
|
||||
"editor.wordWrapColumn": 120
|
||||
},
|
||||
"better-comments.tags": [
|
||||
{
|
||||
"tag": "XXX",
|
||||
"color": "#F8C471"
|
||||
},
|
||||
{
|
||||
"tag": "WARN",
|
||||
"color": "#FF6961"
|
||||
},
|
||||
{
|
||||
"tag": "NOTE",
|
||||
"color": "#3498DB"
|
||||
},
|
||||
{
|
||||
"tag": "TODO",
|
||||
"color": "#77C3EC"
|
||||
}
|
||||
],
|
||||
"vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
|
||||
"codesnap.showWindowControls": false,
|
||||
"codesnap.shutterAction": "copy",
|
||||
"Workspace_Formatter.excludePattern": [
|
||||
"**/build",
|
||||
"**/.*",
|
||||
"**/.vscode",
|
||||
"**/html"
|
||||
],
|
||||
"Workspace_Formatter.includePattern": [
|
||||
"*.c",
|
||||
"*.h",
|
||||
"*.cc",
|
||||
"*.hh",
|
||||
"*.cpp",
|
||||
"*.hpp"
|
||||
],
|
||||
"svg.preview.autoOpen": true,
|
||||
"remote.WSL.fileWatcher.polling": true,
|
||||
"errorLens.delay": 1000,
|
||||
"errorLens.enabledDiagnosticLevels": [
|
||||
"error",
|
||||
"warning"
|
||||
],
|
||||
"errorLens.enabled": false,
|
||||
"C_Cpp.clang_format_sortIncludes": true,
|
||||
"C_Cpp.vcFormat.indent.preserveComments": true,
|
||||
"C_Cpp.vcFormat.indent.namespaceContents": false,
|
||||
"C_Cpp.vcFormat.indent.caseContentsWhenBlock": true,
|
||||
"C_Cpp.vcFormat.space.pointerReferenceAlignment": "right",
|
||||
"C_Cpp.default.browse.limitSymbolsToIncludedHeaders": false,
|
||||
"C_Cpp.default.cppStandard": "c++20",
|
||||
"C_Cpp.default.cStandard": "c11",
|
||||
"C_Cpp.formatting": "clangFormat",
|
||||
"[c]": {
|
||||
"editor.formatOnSave": false,
|
||||
"editor.defaultFormatter": "ms-vscode.cpptools"
|
||||
},
|
||||
"[cpp]": {
|
||||
"editor.formatOnSave": false,
|
||||
"editor.defaultFormatter": "ms-vscode.cpptools"
|
||||
},
|
||||
"[cuda-cpp]": {
|
||||
"editor.defaultFormatter": "ms-vscode.cpptools"
|
||||
},
|
||||
"cmake.configureOnOpen": false,
|
||||
"cmake.autoSelectActiveFolder": false,
|
||||
"cmake.configureOnEdit": false,
|
||||
"[cmake]": {
|
||||
"editor.formatOnSave": false,
|
||||
"editor.defaultFormatter": "cheshirekow.cmake-format"
|
||||
},
|
||||
"cmake.options.statusBarVisibility": "visible",
|
||||
"doxdocgen.file.fileTemplate": "@file {name}",
|
||||
"doxdocgen.cpp.tparamTemplate": "@tparam {param} ",
|
||||
"doxdocgen.generic.briefTemplate": "@brief {text}",
|
||||
"doxdocgen.generic.boolReturnsTrueFalse": false,
|
||||
"doxdocgen.generic.paramTemplate": "@param {param} ",
|
||||
"doxdocgen.generic.returnTemplate": "@return",
|
||||
"doxdocgen.generic.includeTypeAtReturn": false,
|
||||
"C_Cpp.codeAnalysis.clangTidy.enabled": false,
|
||||
"C_Cpp.configurationWarnings": "disabled",
|
||||
"C_Cpp_Runner.cppStandard": "c++20",
|
||||
"C_Cpp_Runner.cStandard": "c11",
|
||||
"C_Cpp_Runner.enableWarnings": true,
|
||||
"C_Cpp_Runner.warningsAsError": false,
|
||||
"C_Cpp_Runner.cCompilerPath": "gcc",
|
||||
"C_Cpp_Runner.cppCompilerPath": "g++",
|
||||
"C_Cpp_Runner.debuggerPath": "gdb",
|
||||
"C_Cpp_Runner.cStandard": "",
|
||||
"C_Cpp_Runner.cppStandard": "c++23",
|
||||
"C_Cpp_Runner.msvcBatchPath": "C:/Program Files/Microsoft Visual Studio/VR_NR/Community/VC/Auxiliary/Build/vcvarsall.bat",
|
||||
"C_Cpp_Runner.useMsvc": false,
|
||||
"C_Cpp_Runner.warnings": [
|
||||
"-Wall",
|
||||
@ -33,8 +165,6 @@
|
||||
"/w44265",
|
||||
"/w14928"
|
||||
],
|
||||
"C_Cpp_Runner.enableWarnings": true,
|
||||
"C_Cpp_Runner.warningsAsError": false,
|
||||
"C_Cpp_Runner.compilerArgs": [],
|
||||
"C_Cpp_Runner.linkerArgs": [],
|
||||
"C_Cpp_Runner.includePaths": [],
|
||||
@ -55,5 +185,6 @@
|
||||
"C_Cpp_Runner.useLeakSanitizer": false,
|
||||
"C_Cpp_Runner.showCompilationTime": false,
|
||||
"C_Cpp_Runner.useLinkTimeOptimization": false,
|
||||
"C_Cpp_Runner.msvcSecureNoWarnings": false
|
||||
"C_Cpp_Runner.msvcSecureNoWarnings": false,
|
||||
"C_Cpp_Runner.msvcBatchPath": ""
|
||||
}
|
329
main.cpp
329
main.cpp
@ -0,0 +1,329 @@
|
||||
#include "iostream"
|
||||
#include <algorithm>
|
||||
#include <cstdlib>
|
||||
|
||||
using namespace std;
|
||||
|
||||
string clear_command;
|
||||
|
||||
//Kajetan Pietrzak
|
||||
//Zgadywanie
|
||||
|
||||
void clear_screen() {
|
||||
#ifdef _WIN32
|
||||
system("cls");
|
||||
#elif defined(__unix__) || defined(__unix) || defined(__linux__) || defined(__APPLE__)
|
||||
system("clear");
|
||||
#endif
|
||||
}
|
||||
|
||||
int main() {
|
||||
//Ponieważ mój system (code-server) znajduje się na linux, użyję system("clear");
|
||||
//Aby wyczyścić na windows, należy użyć: system("cls");
|
||||
#ifdef _WIN32
|
||||
#elif defined(__unix__) || defined(__unix) || defined(__linux__) || defined(__APPLE__)
|
||||
#else
|
||||
cout << "Nie potrafię określić twojego systemu!" << endl;
|
||||
exit(1);
|
||||
#endif
|
||||
|
||||
int opcja;
|
||||
cout << "1. Zgadywanie liczb." << endl;
|
||||
cout << "2. Papier, kamień, nożyce." << endl;
|
||||
cout << "Wybierz grę: ";
|
||||
|
||||
if(!(cin >> opcja) || (opcja != 1 && opcja != 2)) {
|
||||
cout << "To nie jest poprawna opcja!" << endl; //Nie panikujemy, tylko "grzecznie" udajemy, że problemu nie ma :P
|
||||
exit(1);
|
||||
}
|
||||
|
||||
clear_screen();
|
||||
|
||||
if(opcja == 1) {
|
||||
int rund = 0;
|
||||
int proby[1000] = {0};
|
||||
|
||||
bool done = false;
|
||||
do {
|
||||
|
||||
cout << "1. Gra z komputerem." << endl;
|
||||
cout << "2. Gra z drugim graczem" << endl;
|
||||
cout << "3. Wyjście" << endl;
|
||||
cout << "Wybierz tryb: ";
|
||||
|
||||
if(!(cin >> opcja) || (opcja != 1 && opcja != 2 && opcja != 3)) {
|
||||
cout << "To nie jest poprawna opcja!" << endl; //Nie panikujemy, tylko "grzecznie" udajemy, że problemu nie ma :P
|
||||
exit(1);
|
||||
} else if (opcja == 3) {
|
||||
cout << "Dziękuję za udział!" << endl;
|
||||
cout << "Grałeś " << rund << " razy!" << endl;
|
||||
int suma = 0;
|
||||
for(int i = 0; i<rund; i++) {
|
||||
if(proby[i] == 0) break;
|
||||
suma += proby[i];
|
||||
}
|
||||
cout << "Średni wynik (liczba prób): " << suma/rund << endl;
|
||||
done = true;
|
||||
exit(0);
|
||||
}
|
||||
|
||||
rund += 1;
|
||||
|
||||
if(opcja == 1) {
|
||||
int ilosc = 0;
|
||||
|
||||
clear_screen();
|
||||
bool done_game = false;
|
||||
|
||||
srand(time(0)); //Ustawiamy ziarno losowości (bez tego, liczba zawsze jest praktycznie taka sama!)
|
||||
int x = (rand() % (100 + 1));
|
||||
|
||||
cout << "Komputer wybrał liczbę..." << endl;
|
||||
|
||||
do {
|
||||
cout << "Spróbuj zgadnąć liczbę: " << endl;
|
||||
int y;
|
||||
ilosc++;
|
||||
if(cin >> y) {
|
||||
int odleglosc = y-x;
|
||||
|
||||
if(odleglosc > 0) {
|
||||
if(odleglosc < 50) {
|
||||
if(odleglosc < 35) {
|
||||
if(odleglosc < 20) {
|
||||
if(odleglosc < 10) {
|
||||
if(odleglosc < 5) {
|
||||
if(odleglosc == 0) {
|
||||
cout << "Zgadłeś!" << endl;
|
||||
done_game = true;
|
||||
} else {
|
||||
cout << "Bardzo gorąco!!!!!!!!" << endl;
|
||||
}
|
||||
} else {
|
||||
cout << "Bardzo ciepło! (za dużo)" << endl;
|
||||
}
|
||||
} else {
|
||||
cout << "Ciepło! (za dużo)" << endl;
|
||||
}
|
||||
} else {
|
||||
cout << "No coś tak, tak letnio... (za dużo)" << endl;
|
||||
}
|
||||
} else {
|
||||
cout << "Zimno! (za dużo)" << endl;
|
||||
}
|
||||
} else {
|
||||
cout << "Bardzo zimno! (dużo za dużo)" << endl;
|
||||
}
|
||||
} else {
|
||||
if(odleglosc > -50) {
|
||||
if(odleglosc > -35) {
|
||||
if(odleglosc > -20) {
|
||||
if(odleglosc > -10) {
|
||||
if(odleglosc > -5) {
|
||||
if(odleglosc == 0) {
|
||||
cout << "Zgadłeś!" << endl;
|
||||
done_game = true;
|
||||
} else {
|
||||
cout << "Bardzo gorąco!!!!!!!!" << endl;
|
||||
}
|
||||
} else {
|
||||
cout << "Bardzo ciepło! (za mało)" << endl;
|
||||
}
|
||||
} else {
|
||||
cout << "Ciepło! (za mało)" << endl;
|
||||
}
|
||||
} else {
|
||||
cout << "No coś tak, tak letnio... (za mało)" << endl;
|
||||
}
|
||||
} else {
|
||||
cout << "Zimno! (za mało)" << endl;
|
||||
}
|
||||
} else {
|
||||
cout << "Bardzo zimno! (dużo za mało!)" << endl;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
cout << "To nie jest liczba całkowita!" << endl;
|
||||
exit(1);
|
||||
}
|
||||
} while(!done_game);
|
||||
cout << "Całkowita liczba prób: " << ilosc << endl;
|
||||
proby[rund-1] = ilosc;
|
||||
}
|
||||
|
||||
if(opcja == 2) {
|
||||
int x;
|
||||
int ilosc = 0;
|
||||
|
||||
clear_screen();
|
||||
|
||||
cout << "Podaj liczbę, który drugi użytkownik będzie zgadywał: ";
|
||||
if(cin >> x) {
|
||||
//Ponieważ mój system (code-server) znajduje się na linux, użyję system("clear");
|
||||
//Aby wyczyścić na windows, należy użyć: system("cls");
|
||||
clear_screen();
|
||||
|
||||
bool done_game = false;
|
||||
|
||||
do {
|
||||
cout << "Spróbuj zgadnąć liczbę: " << endl;
|
||||
int y;
|
||||
ilosc++;
|
||||
if(cin >> y) {
|
||||
int odleglosc = y-x;
|
||||
|
||||
if(odleglosc > 0) {
|
||||
if(odleglosc < 50) {
|
||||
if(odleglosc < 35) {
|
||||
if(odleglosc < 20) {
|
||||
if(odleglosc < 10) {
|
||||
if(odleglosc < 5) {
|
||||
if(odleglosc == 0) {
|
||||
cout << "Zgadłeś!" << endl;
|
||||
done_game = true;
|
||||
} else {
|
||||
cout << "Bardzo gorąco!!!!!!!!" << endl;
|
||||
}
|
||||
} else {
|
||||
cout << "Bardzo ciepło! (za dużo)" << endl;
|
||||
}
|
||||
} else {
|
||||
cout << "Ciepło! (za dużo)" << endl;
|
||||
}
|
||||
} else {
|
||||
cout << "No coś tak, tak letnio... (za dużo)" << endl;
|
||||
}
|
||||
} else {
|
||||
cout << "Zimno! (za dużo)" << endl;
|
||||
}
|
||||
} else {
|
||||
cout << "Bardzo zimno! (dużo za dużo)" << endl;
|
||||
}
|
||||
} else {
|
||||
if(odleglosc > -50) {
|
||||
if(odleglosc > -35) {
|
||||
if(odleglosc > -20) {
|
||||
if(odleglosc > -10) {
|
||||
if(odleglosc > -5) {
|
||||
if(odleglosc == 0) {
|
||||
cout << "Zgadłeś!" << endl;
|
||||
done_game = true;
|
||||
} else {
|
||||
cout << "Bardzo gorąco!!!!!!!!" << endl;
|
||||
}
|
||||
} else {
|
||||
cout << "Bardzo ciepło! (za mało)" << endl;
|
||||
}
|
||||
} else {
|
||||
cout << "Ciepło! (za mało)" << endl;
|
||||
}
|
||||
} else {
|
||||
cout << "No coś tak, tak letnio... (za mało)" << endl;
|
||||
}
|
||||
} else {
|
||||
cout << "Zimno! (za mało)" << endl;
|
||||
}
|
||||
} else {
|
||||
cout << "Bardzo zimno! (dużo za mało!)" << endl;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
cout << "To nie jest liczba całkowita!" << endl;
|
||||
exit(1);
|
||||
}
|
||||
} while(!done_game);
|
||||
proby[rund-1] = ilosc;
|
||||
cout << "Całkowita liczba prób: " << ilosc << endl;
|
||||
} else {
|
||||
cout << "To nie jest liczba całkowita!" << endl;
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
} while(!done);
|
||||
}
|
||||
|
||||
if(opcja == 2) {
|
||||
int remis = 0;
|
||||
int wygrana = 0;
|
||||
int przegrana = 0;
|
||||
|
||||
bool done = false;
|
||||
|
||||
do {
|
||||
cout << "Komputer wybrał..." << endl;
|
||||
srand(time(0)); //Ustawiamy ziarno losowości (bez tego, liczba zawsze jest praktycznie taka sama!)
|
||||
int random_number = (rand() % (2 + 1));
|
||||
|
||||
cout << "1. Kamień" << endl;
|
||||
cout << "2. Papier" << endl;
|
||||
cout << "3. Nożyce" << endl;
|
||||
cout << "4. Wyjście" << endl;
|
||||
cout << "Wygranych: " << wygrana << " Przegranych: " << przegrana << " Remis: " << remis << " Rund: " << przegrana + wygrana + remis << endl;
|
||||
cout << "Twój wybór: ";
|
||||
int wybor;
|
||||
cin >> wybor;
|
||||
if(wybor == 4) {
|
||||
cout << "Wygranych: " << wygrana << " Przegranych: " << przegrana << " Remis: " << remis << " Rund: " << przegrana + wygrana + remis << endl;
|
||||
cout << "Dziękuję za grę!" << endl;
|
||||
done = true;
|
||||
exit(0);
|
||||
}
|
||||
|
||||
clear_screen();
|
||||
|
||||
if(random_number == (wybor-1)) {
|
||||
cout << "Remis!" << endl;
|
||||
remis++;
|
||||
}
|
||||
|
||||
//Wykluczulyśmi remis!
|
||||
|
||||
string komputer = (random_number == 0) ? "Kamień" : (random_number == 1) ? "Papier" : "Nożyce";
|
||||
string human = (wybor == 1) ? "Kamień" : (wybor == 2) ? "Papier" : "Nożyce";
|
||||
cout << "Komputer wybrał " << komputer << ", a ty " << human << endl;
|
||||
|
||||
|
||||
if(random_number == 0) {
|
||||
if(wybor == 2) {
|
||||
cout << "Wygrana!" << endl;
|
||||
wygrana++;
|
||||
cout << endl << "Wpisz cokolwiek i nacisnij enter aby kontynuować!";
|
||||
char dummy;
|
||||
cin >> dummy;
|
||||
continue;
|
||||
}
|
||||
cout << "Przegrana!" << endl; //Możemy pominąć ifa, bo wykluczyłem remis!
|
||||
przegrana++;
|
||||
}
|
||||
if(random_number == 1) {
|
||||
if(wybor == 3) {
|
||||
cout << "Wygrana!" << endl;
|
||||
wygrana++;
|
||||
cout << endl << "Wpisz cokolwiek i nacisnij enter aby kontynuować!";
|
||||
char dummy;
|
||||
cin >> dummy;
|
||||
continue;
|
||||
}
|
||||
cout << "Przegrana!" << endl;
|
||||
przegrana++;
|
||||
}
|
||||
if(random_number == 2) {
|
||||
if(wybor == 1) {
|
||||
cout << "Wygrana!" << endl;
|
||||
wygrana++;
|
||||
cout << endl << "Wpisz cokolwiek i nacisnij enter aby kontynuować!";
|
||||
char dummy;
|
||||
cin >> dummy;
|
||||
continue;
|
||||
}
|
||||
cout << "Przegrana!" << endl;
|
||||
przegrana++;
|
||||
}
|
||||
cout << endl << "Wpisz cokolwiek i nacisnij enter aby kontynuować!";
|
||||
char dummy;
|
||||
cin >> dummy;
|
||||
} while (!done);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user