aboutsummaryrefslogtreecommitdiffstats
path: root/ee1301/wk5/lab4/strap012_lab4_w_2.cpp
diff options
context:
space:
mode:
authorRossTheRoss <msattr@gmail.com>2019-06-25 17:55:13 -0500
committerRossTheRoss <msattr@gmail.com>2019-06-25 17:55:13 -0500
commit6c83506cb44b1d20f66df404f0b6468b0e291b6b (patch)
tree8e0475edc2891741862bc9b63844600bdebe6936 /ee1301/wk5/lab4/strap012_lab4_w_2.cpp
parentM E A N I N G F U L C O M M E N T S (diff)
downloadhomework-6c83506cb44b1d20f66df404f0b6468b0e291b6b.tar
homework-6c83506cb44b1d20f66df404f0b6468b0e291b6b.tar.gz
homework-6c83506cb44b1d20f66df404f0b6468b0e291b6b.tar.bz2
homework-6c83506cb44b1d20f66df404f0b6468b0e291b6b.tar.lz
homework-6c83506cb44b1d20f66df404f0b6468b0e291b6b.tar.xz
homework-6c83506cb44b1d20f66df404f0b6468b0e291b6b.tar.zst
homework-6c83506cb44b1d20f66df404f0b6468b0e291b6b.zip
Do a thing:
Diffstat (limited to 'ee1301/wk5/lab4/strap012_lab4_w_2.cpp')
-rw-r--r--ee1301/wk5/lab4/strap012_lab4_w_2.cpp108
1 files changed, 54 insertions, 54 deletions
diff --git a/ee1301/wk5/lab4/strap012_lab4_w_2.cpp b/ee1301/wk5/lab4/strap012_lab4_w_2.cpp
index 1574abc..5b82cd4 100644
--- a/ee1301/wk5/lab4/strap012_lab4_w_2.cpp
+++ b/ee1301/wk5/lab4/strap012_lab4_w_2.cpp
@@ -1,54 +1,54 @@
-#include <iostream>
-using namespace std;
-
-void bsort(int list[], int length);
-void swap (int &a, int &b);
-void printArray (int list[], int length);
-void makeArray (int list[], int length);
-const int n=50;
-
-int main () {
-int list[n];
-makeArray(list,n);
-bsort(list, n);
-printArray(list, n);
-}
-
-//This function makes the array used for the rest of the program.
-void makeArray(int list[], int length) {
- int temp=100;
- for (int i=0; i<n; i++) {
- list[i]=temp;
- temp--;
- }
-}
-
-//This function is the algorithm.
-void bsort(int list[], int length) {
- for (int i=0; i<n; i++) {
- for (int j=0; j<n-1; j++) {
- if (list[j]>list[j+1]) {
- //This is so the bubble can happen
- swap(list[j], list[j+1]);
- }
- }
- }
-}
-
-//This function simply swaps two values so the bubbling can commence
-void swap (int &a, int &b) {
- int temp;
- temp=a; a=b; b=temp;
-}
-
-//This function prints the array at 5 per line.
-void printArray (int list[], int length) {
- int k=0;
- for (int j=0; j<(n/10)*2; j++) {
- for (int i=0; i<5; i++) {
- cout << list[k] << " ";
- k++;
- }
- cout << endl;
- }
-}
+#include <iostream>
+using namespace std;
+
+void bsort(int list[], int length);
+void swap (int &a, int &b);
+void printArray (int list[], int length);
+void makeArray (int list[], int length);
+const int n=50;
+
+int main () {
+int list[n];
+makeArray(list,n);
+bsort(list, n);
+printArray(list, n);
+}
+
+//This function makes the array used for the rest of the program.
+void makeArray(int list[], int length) {
+ int temp=100;
+ for (int i=0; i<n; i++) {
+ list[i]=temp;
+ temp--;
+ }
+}
+
+//This function is the algorithm.
+void bsort(int list[], int length) {
+ for (int i=0; i<n; i++) {
+ for (int j=0; j<n-1; j++) {
+ if (list[j]>list[j+1]) {
+ //This is so the bubble can happen
+ swap(list[j], list[j+1]);
+ }
+ }
+ }
+}
+
+//This function simply swaps two values so the bubbling can commence
+void swap (int &a, int &b) {
+ int temp;
+ temp=a; a=b; b=temp;
+}
+
+//This function prints the array at 5 per line.
+void printArray (int list[], int length) {
+ int k=0;
+ for (int j=0; j<(n/10)*2; j++) {
+ for (int i=0; i<5; i++) {
+ cout << list[k] << " ";
+ k++;
+ }
+ cout << endl;
+ }
+}