From e87d1f440eb0e3a7b07e5dc8bcd91153a1efa8d6 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 24 Aug 2021 14:44:32 +0800 Subject: [PATCH] First commit --- .vscode/c_cpp_properties.json | 20 +++++++++++++++ .vscode/launch.json | 29 ++++++++++++++++++++++ .vscode/settings.json | 8 ++++++ .vscode/tasks.json | 46 +++++++++++++++++++++++++++++++++++ BubbleSort.cpp | 46 +++++++++++++++++++++++++++++++++++ 5 files changed, 149 insertions(+) create mode 100644 .vscode/c_cpp_properties.json create mode 100644 .vscode/launch.json create mode 100644 .vscode/settings.json create mode 100644 .vscode/tasks.json create mode 100644 BubbleSort.cpp diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..7208951 --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,20 @@ +{ + "configurations": [ + { + "name": "Win32", + "includePath": [ + "${workspaceFolder}/**" + ], + "defines": [ + "_DEBUG", + "UNICODE", + "_UNICODE" + ], + "cStandard": "c17", + "cppStandard": "c++17", + "intelliSenseMode": "gcc-x64", + "compilerPath": "C:\\msys64\\mingw64\\bin\\g++.exe" + } + ], + "version": 4 +} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..8594282 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,29 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "g++.exe - Build and debug active file", + "type": "cppdbg", + "request": "launch", + "program": "${fileDirname}\\${fileBasenameNoExtension}.exe", + "args": [], + "stopAtEntry": false, + "cwd": "${fileDirname}", + "environment": [], + "externalConsole": false, + "MIMode": "gdb", + "miDebuggerPath": "C:\\msys64\\mingw64\\bin\\gdb.exe", + "setupCommands": [ + { + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing", + "ignoreFailures": true + } + ], + "preLaunchTask": "C/C++: g++.exe build active file ver(1)" + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..abd04df --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,8 @@ +{ + "C_Cpp.errorSquiggles": "Disabled", + "files.associations": { + "iostream": "cpp", + "cstdio": "cpp", + "string": "cpp" + } +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..e2744c0 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,46 @@ +{ + "tasks": [ + { + "type": "cppbuild", + "label": "C/C++: g++.exe build active file", + "command": "C:\\msys64\\mingw64\\bin\\g++.exe", + "args": [ + "-g", + "${file}", + "-o", + "${fileDirname}\\${fileBasenameNoExtension}.exe" + ], + "options": { + "cwd": "${fileDirname}" + }, + "problemMatcher": [ + "$gcc" + ], + "group": "build", + "detail": "Task generated by Debugger." + }, + { + "type": "cppbuild", + "label": "C/C++: g++.exe build active file ver(1)", + "command": "C:\\msys64\\mingw64\\bin\\g++.exe", + "args": [ + "-g", + "${file}", + "-o", + "${fileDirname}\\${fileBasenameNoExtension}.exe" + ], + "options": { + "cwd": "${fileDirname}" + }, + "problemMatcher": [ + "$gcc" + ], + "group": { + "kind": "build", + "isDefault": true + }, + "detail": "Task generated by Debugger." + } + ], + "version": "2.0.0" +} \ No newline at end of file diff --git a/BubbleSort.cpp b/BubbleSort.cpp new file mode 100644 index 0000000..752c427 --- /dev/null +++ b/BubbleSort.cpp @@ -0,0 +1,46 @@ +#include + +/* + *This was coded by Darrel Israel + *Do not change anything! + */ + +using namespace std; +//Bubble sort algorithm +void bubbleSortNamesAscending(string name[], int arr_size) +{ + string temp; + for (int i = 0; i < arr_size; i++) + { + for (int j = i + 1; j < arr_size; j++) + { + if(name[i] > name[j]) + { + temp = name[i]; + name[i] = name[j]; + name[j] = temp; + } + } + } +} + +int main() +{ + const int arr_size = 10; + int age[arr_size]; + string name[arr_size], temp; + //for loop to ask the user for the students name and age + for (int i = 0; i < arr_size; i++) + { + // user input for name + cout << "Enter the name of student " << i+1 << ": "; + getline(cin, name[i]); + cin.clear(); + } + //for loop to display names in ascending order + bubbleSortNamesAscending(name, arr_size); + for (int i = 0; i < arr_size; i++) + { + cout << name[i] << " "; + } +} \ No newline at end of file