Created
November 10, 2014 01:46
-
-
Save StabbyMcDuck/91b86bc8de78affd3f63 to your computer and use it in GitHub Desktop.
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
#include <iostream> | |
#include <fstream> | |
#include <string> | |
//*********************************** | |
// A program to search through 4 different files looking for a number, 5 | |
//*********************************** | |
void insertSort(int arrayToSort[], int arraySize){ | |
for(int i = 1; i < arraySize; i++){ | |
int x = arrayToSort[i] | |
int arrayNumb = arrayToSort[i]; | |
while((i > 0) && (arrayToSort[i-1] > x){ | |
arrayToSort[i] = arrayToSort[i-1]; | |
i--; | |
} | |
arrayToSort[i] = x; | |
} | |
} | |
void printArray(int arrayPrint[], int arrayLength){ | |
for(int i = 0; i < arrayLength; i++){ | |
std::cout << arrayPrint[i] << endl; | |
} | |
} | |
bool searchBinary(int arrayCheck[], int arrayLength){ | |
int start = 0; | |
int end = arrayLength - 1; | |
int middle = ((end - start) / 2); | |
while((arrayCheck[middle] != 5)){ | |
if(arrayCheck[middle] < 5){ | |
start = middle; | |
middle = ((end - start)/2) + start; | |
}if(arrayCheck[middle] > 5){ | |
end = middle; | |
middle = (end - start)/2) + start; | |
}else if(end == middle){ | |
break; | |
}else if(start == middle){ | |
break; | |
} | |
} | |
if(arrayCheck[middle] == 5){ | |
return true; | |
}else{ | |
return false; | |
} | |
} | |
void hasAFive(){ | |
if(missing == true){ | |
std::cout << "This file has a 5!" << std::endl; | |
}else{ | |
std::cout << "This file has no 5 :( " << std::endl; | |
} | |
} | |
int main(){ | |
std::ifstream no5("no5.txt"); | |
std::ifstream early("early.txt"); | |
std::ifstream middle("middle.txt"); | |
std::ifstream end("end.txt"); | |
int no5Char; | |
int earlyChar; | |
int middleChar; | |
int endChar; | |
bool no5 = false; | |
bool early = false; | |
bool middle = false; | |
bool end = false; | |
arraySize = 20; | |
int no5[arraySize]; | |
int early[arraySize]; | |
int middle[arraySize]; | |
int end[arraySize]; | |
for(int = 0; i < arraySize; i++){ | |
no5 >> no5Char; | |
if(no5Char = 5){ | |
no5 = true; | |
} | |
no5[i] = no5Char; | |
} | |
void hasAFive(); | |
for(int = 0; i < arraySize; i++){ | |
no5 >> no5Char; | |
if(no5Char = 5){ | |
no5 = true; | |
} | |
no5[i] = no5Char; | |
} | |
void hasAFive(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment