diff options
| author | tylr <[email protected]> | 2021-12-03 09:54:33 -0800 |
|---|---|---|
| committer | tylr <[email protected]> | 2021-12-03 09:54:33 -0800 |
| commit | 68106d94900af8c5b4d57e2b15752167393e7338 (patch) | |
| tree | 22c8aa405aa1ebe7133c1be53044008466b3962b | |
| parent | Adding num2 folder that contains data file and code. (diff) | |
| download | cst116-lab9-till-t-68106d94900af8c5b4d57e2b15752167393e7338.tar.xz cst116-lab9-till-t-68106d94900af8c5b4d57e2b15752167393e7338.zip | |
Added additional data files. Number 2 complete.
| -rw-r--r-- | lab9/lab9.xcodeproj/project.pbxproj | 284 | ||||
| -rw-r--r-- | lab9/lab9.xcodeproj/project.xcworkspace/contents.xcworkspacedata | 7 | ||||
| -rw-r--r-- | lab9/lab9.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist | 8 | ||||
| -rw-r--r-- | lab9/lab9.xcodeproj/project.xcworkspace/xcuserdata/tylertaormina.xcuserdatad/UserInterfaceState.xcuserstate | bin | 0 -> 16717 bytes | |||
| -rw-r--r-- | lab9/lab9.xcodeproj/xcuserdata/tylertaormina.xcuserdatad/xcschemes/xcschememanagement.plist | 14 | ||||
| -rw-r--r-- | lab9/lab9/data.txt (renamed from num2/data.txt) | 0 | ||||
| -rw-r--r-- | lab9/lab9/main.cpp | 115 | ||||
| -rwxr-xr-x | num2/a.out | bin | 69858 -> 75266 bytes | |||
| -rw-r--r-- | num2/data2.txt | 10 | ||||
| -rw-r--r-- | num2/hello.txt | 10 | ||||
| -rw-r--r-- | num2/num2.cpp | 41 |
11 files changed, 478 insertions, 11 deletions
diff --git a/lab9/lab9.xcodeproj/project.pbxproj b/lab9/lab9.xcodeproj/project.pbxproj new file mode 100644 index 0000000..1d19a18 --- /dev/null +++ b/lab9/lab9.xcodeproj/project.pbxproj @@ -0,0 +1,284 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 55; + objects = { + +/* Begin PBXBuildFile section */ + 4F6E708B2758AF5D00A8F399 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4F6E708A2758AF5D00A8F399 /* main.cpp */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 4F6E70852758AF5D00A8F399 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + ); + runOnlyForDeploymentPostprocessing = 1; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 4F6E70872758AF5D00A8F399 /* lab9 */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = lab9; sourceTree = BUILT_PRODUCTS_DIR; }; + 4F6E708A2758AF5D00A8F399 /* main.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; }; + 4F6E70912758AF7300A8F399 /* num2 */ = {isa = PBXFileReference; lastKnownFileType = folder; name = num2; path = ../num2; sourceTree = "<group>"; }; + 4F6E70922758AFE500A8F399 /* data.txt */ = {isa = PBXFileReference; lastKnownFileType = text; path = data.txt; sourceTree = "<group>"; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 4F6E70842758AF5D00A8F399 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 4F6E707E2758AF5D00A8F399 = { + isa = PBXGroup; + children = ( + 4F6E70912758AF7300A8F399 /* num2 */, + 4F6E70892758AF5D00A8F399 /* lab9 */, + 4F6E70882758AF5D00A8F399 /* Products */, + ); + sourceTree = "<group>"; + }; + 4F6E70882758AF5D00A8F399 /* Products */ = { + isa = PBXGroup; + children = ( + 4F6E70872758AF5D00A8F399 /* lab9 */, + ); + name = Products; + sourceTree = "<group>"; + }; + 4F6E70892758AF5D00A8F399 /* lab9 */ = { + isa = PBXGroup; + children = ( + 4F6E708A2758AF5D00A8F399 /* main.cpp */, + 4F6E70922758AFE500A8F399 /* data.txt */, + ); + path = lab9; + sourceTree = "<group>"; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 4F6E70862758AF5D00A8F399 /* lab9 */ = { + isa = PBXNativeTarget; + buildConfigurationList = 4F6E708E2758AF5D00A8F399 /* Build configuration list for PBXNativeTarget "lab9" */; + buildPhases = ( + 4F6E70832758AF5D00A8F399 /* Sources */, + 4F6E70842758AF5D00A8F399 /* Frameworks */, + 4F6E70852758AF5D00A8F399 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = lab9; + productName = lab9; + productReference = 4F6E70872758AF5D00A8F399 /* lab9 */; + productType = "com.apple.product-type.tool"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 4F6E707F2758AF5D00A8F399 /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = 1; + LastUpgradeCheck = 1310; + TargetAttributes = { + 4F6E70862758AF5D00A8F399 = { + CreatedOnToolsVersion = 13.1; + }; + }; + }; + buildConfigurationList = 4F6E70822758AF5D00A8F399 /* Build configuration list for PBXProject "lab9" */; + compatibilityVersion = "Xcode 13.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 4F6E707E2758AF5D00A8F399; + productRefGroup = 4F6E70882758AF5D00A8F399 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 4F6E70862758AF5D00A8F399 /* lab9 */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + 4F6E70832758AF5D00A8F399 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 4F6E708B2758AF5D00A8F399 /* main.cpp in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 4F6E708C2758AF5D00A8F399 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 12.0; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + }; + name = Debug; + }; + 4F6E708D2758AF5D00A8F399 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 12.0; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = macosx; + }; + name = Release; + }; + 4F6E708F2758AF5D00A8F399 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 4F6E70902758AF5D00A8F399 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 4F6E70822758AF5D00A8F399 /* Build configuration list for PBXProject "lab9" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 4F6E708C2758AF5D00A8F399 /* Debug */, + 4F6E708D2758AF5D00A8F399 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 4F6E708E2758AF5D00A8F399 /* Build configuration list for PBXNativeTarget "lab9" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 4F6E708F2758AF5D00A8F399 /* Debug */, + 4F6E70902758AF5D00A8F399 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 4F6E707F2758AF5D00A8F399 /* Project object */; +} diff --git a/lab9/lab9.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/lab9/lab9.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/lab9/lab9.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<Workspace + version = "1.0"> + <FileRef + location = "self:"> + </FileRef> +</Workspace> diff --git a/lab9/lab9.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/lab9/lab9.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/lab9/lab9.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>IDEDidComputeMac32BitWarning</key> + <true/> +</dict> +</plist> diff --git a/lab9/lab9.xcodeproj/project.xcworkspace/xcuserdata/tylertaormina.xcuserdatad/UserInterfaceState.xcuserstate b/lab9/lab9.xcodeproj/project.xcworkspace/xcuserdata/tylertaormina.xcuserdatad/UserInterfaceState.xcuserstate Binary files differnew file mode 100644 index 0000000..678e2fb --- /dev/null +++ b/lab9/lab9.xcodeproj/project.xcworkspace/xcuserdata/tylertaormina.xcuserdatad/UserInterfaceState.xcuserstate diff --git a/lab9/lab9.xcodeproj/xcuserdata/tylertaormina.xcuserdatad/xcschemes/xcschememanagement.plist b/lab9/lab9.xcodeproj/xcuserdata/tylertaormina.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..d2e1464 --- /dev/null +++ b/lab9/lab9.xcodeproj/xcuserdata/tylertaormina.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>SchemeUserState</key> + <dict> + <key>lab9.xcscheme_^#shared#^_</key> + <dict> + <key>orderHint</key> + <integer>0</integer> + </dict> + </dict> +</dict> +</plist> diff --git a/num2/data.txt b/lab9/lab9/data.txt index d28c343..d28c343 100644 --- a/num2/data.txt +++ b/lab9/lab9/data.txt diff --git a/lab9/lab9/main.cpp b/lab9/lab9/main.cpp new file mode 100644 index 0000000..e6bcc54 --- /dev/null +++ b/lab9/lab9/main.cpp @@ -0,0 +1,115 @@ +#include <iostream> +#include <fstream> // For the files!!!! +#include <iomanip> // For manipulators & formatting options +#include <stdio.h> + +using std::cin; +using std::cout; +using std::endl; +using std::setw; +using std::ios; +using std::resetiosflags; +using std::setiosflags; + +using std::ifstream; +using std::ofstream; +const int MAX = 10; + +int ReadData ( ifstream &inFile, int data_arr[]); +void Sort (int data_arr[], int counter); +void Display_LS(int data_arr[], int counter); + + +int main() +{ + int i; + int record_counter = 0; + int data[MAX]; + + ifstream inFile; + + // Notice how this automatically opens the file + + inFile.open ( "data.txt"); + + if ( inFile.is_open ( ) ) + { + + record_counter = ReadData (inFile, data); + inFile.close ( ); + } + + else + { + cout << "Trouble Opening File: inFile"; + cout << "\n\n\t\t ** About to EXIT NOW! ** "; + } + + Display_LS(data, record_counter); + + Sort(data, record_counter); + + for (i = 0; i < record_counter; i++) + cout << data[i] << endl; + + return 0; + +} + + +int ReadData(ifstream &inFile, int data_arr[]) +{ + int counter = 0; + inFile >> data_arr[counter]; // Priming Read + + while ( !inFile.eof ( ) ) + { + counter++; + inFile >> data_arr[counter] ; + } + + return counter; +} + + +void Sort (int data_arr[], int counter) +{ + int i; + int j; + int temp; + + for (i = 0; i < counter; i++) + { + for (j = i+1; j < counter; j++) + { + if (data_arr[i] > data_arr[j]) + { + temp = data_arr[i]; + data_arr[i] = data_arr[j]; + data_arr[j] = temp; + } + } + } +} + + +void Display_LS(int data_arr[], int counter) +{ + int large, small; + int i; + small = data_arr[0]; + large = data_arr[0]; + for (i = 1; i < counter; i++) + { + if (small > data_arr[i]) + small = data_arr[i]; + if (large < data_arr[i]) + large = data_arr[i]; + + } + + cout << "The smallest number is: " << small << endl; + cout << "The largest number is: " << large << endl; + +} + Binary files differdiff --git a/num2/data2.txt b/num2/data2.txt new file mode 100644 index 0000000..d28c343 --- /dev/null +++ b/num2/data2.txt @@ -0,0 +1,10 @@ +120 +234 +33 +2021 +44 +23 +530 +567 +340 +501 diff --git a/num2/hello.txt b/num2/hello.txt new file mode 100644 index 0000000..d28c343 --- /dev/null +++ b/num2/hello.txt @@ -0,0 +1,10 @@ +120 +234 +33 +2021 +44 +23 +530 +567 +340 +501 diff --git a/num2/num2.cpp b/num2/num2.cpp index 1426386..18f17bf 100644 --- a/num2/num2.cpp +++ b/num2/num2.cpp @@ -2,6 +2,8 @@ #include <fstream> // For the files!!!! #include <iomanip> // For manipulators & formatting options #include <stdio.h> +#include <string> +#include <algorithm> using std::cin; using std::cout; @@ -13,47 +15,65 @@ using std::setiosflags; using std::ifstream; using std::ofstream; - const int MAX = 10; -int ReadData ( ifstream &inFile, int data_arr[]); +int ReadData (ifstream &inFile, int data_arr[]); void Sort (int data_arr[], int counter); void Display_LS(int data_arr[], int counter); int main() { + std::string input; + int i; int record_counter = 0; int data[MAX]; + int flag; + + cout << "THE FILES WE HAVE TO CHOOSE FROM: " << endl; + cout << "===================================================" << endl; + cout << "data.txt" << endl; + cout << "data2.txt" << endl; + cout << "hello.txt\n\n" << endl; + + + cout << "Please enter a name for the file to open: "; + cin >> input; + transform(input.begin(), input.end(), input.begin(), ::tolower); ifstream inFile; // Notice how this automatically opens the file - inFile.open ( "data.txt"); + inFile.open (input); if ( inFile.is_open ( ) ) { record_counter = ReadData (inFile, data); inFile.close ( ); + flag = 1; } else { - cout << "Trouble Opening File: inFile"; + cout << "Trouble Opening File: " << input << endl; + cout << "Check to make sure your spelling is correct for the file you are trying to open. Include .txt or whatever file extension is relevant." << endl; cout << "\n\n\t\t ** About to EXIT NOW! ** "; + flag = 0; } - Display_LS(data, record_counter); + if (flag == 1) + { + Display_LS(data, record_counter); + Sort(data, record_counter); - Sort(data, record_counter); + for (i = 0; i < record_counter; i++) + cout << data[i] << endl; + } - for (i = 0; i < record_counter; i++) - cout << data[i] << endl; - - return 0; + return 0; } @@ -111,5 +131,4 @@ void Display_LS(int data_arr[], int counter) cout << "The smallest number is: " << small << endl; cout << "The largest number is: " << large << endl; - } |