First commit

This commit is contained in:
unknown
2021-08-24 14:44:32 +08:00
commit e87d1f440e
5 changed files with 149 additions and 0 deletions
+20
View File
@@ -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
}
+29
View File
@@ -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)"
}
]
}
+8
View File
@@ -0,0 +1,8 @@
{
"C_Cpp.errorSquiggles": "Disabled",
"files.associations": {
"iostream": "cpp",
"cstdio": "cpp",
"string": "cpp"
}
}
+46
View File
@@ -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"
}
+46
View File
@@ -0,0 +1,46 @@
#include <iostream>
/*
*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] << " ";
}
}