Ledger Nano X - The secure hardware wallet
SHARE
TWEET

Crap

a guest Apr 6th, 2020 163 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  Name: Joshua Simard
  3.  Date: 4/6/2020
  4.  Assignment: EH5
  5.  Description: Using a one-dimensional array. Read in 20 numbers, each of which is between 10 and 100 inclusive.
  6.  As each number is read, validate it and store it in the array only if it is not a duplicate of a number
  7.  already read in. After reading all the values, display only the unique values that the user entered,
  8.  Test case MUST include cases were all values are different, none are different, and a couple of cases
  9.  where there are several duplicates. You should create several files of data, and then read them in as your test cases.
  10.  Notes: This program writes in 5 files at once.
  11. */
  12.  
  13.  
  14. #include <iostream>
  15. #include <fstream>
  16. #include <string>
  17. using namespace std;
  18.  
  19.  
  20. int main() {
  21.  
  22.     int const SIZE = 20;
  23.     int const CASE_NUM = 5;
  24.  
  25.     int arr[21];
  26.     int counter = 1;
  27.  
  28.     for (int g = CASE_NUM; g >= 0; g--) {
  29.  
  30.         string fileName = "file";
  31.         fileName += to_string(g);
  32.         fileName += ".txt";
  33.  
  34.         cout << fileName << endl;
  35.  
  36.         ifstream readIn(fileName);
  37.  
  38.         for (int i = SIZE; i >= 1; i--) {
  39.  
  40.             int temp;
  41.             readIn >> temp;
  42.  
  43.             for (int v = counter; v >= 0; v--) {
  44.  
  45.                 if (temp == arr[v]) {
  46.                     temp = 101;
  47.                 }
  48.  
  49.             }
  50.             if (temp >= 10 && temp <= 100) {
  51.  
  52.                 arr[i] = temp;
  53.  
  54.             }
  55.             else {
  56.  
  57.                 arr[i] = 0;
  58.  
  59.             }
  60.  
  61.             counter++;
  62.         }
  63.  
  64.         for (int i = SIZE; i >= 1; i--) {
  65.  
  66.             if (arr[i] != 0) {
  67.  
  68.                 cout << arr[i] << " :Index: " << i << endl;
  69.  
  70.             }
  71.  
  72.         }
  73.  
  74.         cout << endl << "------------------------------" << endl << endl;
  75.  
  76.     }
  77.  
  78.     system("pause");
  79.  
  80. }
  81.  
  82. /*
  83. In File 5, there is one duplicate. In file 4, all the values are 92.
  84. In files 3, 2, and 1, several items are duplicates.
  85. In file 0, no items are duplicates.
  86. Results:
  87.  
  88. file5.txt
  89. 56 :Index: 20
  90. 24 :Index: 19
  91. 65 :Index: 17
  92. 25 :Index: 16
  93. 25 :Index: 15
  94. 12 :Index: 14
  95. 82 :Index: 13
  96. 23 :Index: 12
  97. 15 :Index: 11
  98. 85 :Index: 10
  99. 95 :Index: 9
  100. 45 :Index: 8
  101. 36 :Index: 7
  102. 24 :Index: 6
  103. 72 :Index: 5
  104. 32 :Index: 3
  105. 62 :Index: 2
  106.  
  107. ------------------------------
  108.  
  109. file4.txt
  110. 92 :Index: 20
  111.  
  112. ------------------------------
  113.  
  114. file3.txt
  115. 81 :Index: 20
  116. 74 :Index: 19
  117. 12 :Index: 18
  118. 55 :Index: 17
  119. 46 :Index: 16
  120. 27 :Index: 15
  121. 44 :Index: 14
  122. 21 :Index: 13
  123. 28 :Index: 12
  124. 99 :Index: 11
  125. 86 :Index: 10
  126. 84 :Index: 7
  127. 78 :Index: 6
  128. 90 :Index: 5
  129. 100 :Index: 3
  130. 82 :Index: 2
  131. 63 :Index: 1
  132.  
  133. ------------------------------
  134.  
  135. file2.txt
  136. 56 :Index: 20
  137. 64 :Index: 18
  138. 36 :Index: 17
  139. 30 :Index: 15
  140. 40 :Index: 13
  141. 69 :Index: 9
  142. 54 :Index: 7
  143. 49 :Index: 6
  144. 21 :Index: 4
  145. 88 :Index: 1
  146.  
  147. ------------------------------
  148.  
  149. file1.txt
  150. 99 :Index: 20
  151. 59 :Index: 19
  152. 61 :Index: 18
  153. 71 :Index: 17
  154. 80 :Index: 16
  155. 25 :Index: 15
  156. 46 :Index: 14
  157. 23 :Index: 13
  158. 15 :Index: 12
  159. 96 :Index: 9
  160. 64 :Index: 8
  161. 73 :Index: 7
  162. 51 :Index: 6
  163. 57 :Index: 5
  164. 54 :Index: 4
  165. 18 :Index: 3
  166. 14 :Index: 2
  167. 28 :Index: 1
  168.  
  169. ------------------------------
  170.  
  171. file0.txt
  172. 88 :Index: 20
  173. 38 :Index: 18
  174. 49 :Index: 17
  175. 36 :Index: 16
  176. 100 :Index: 15
  177. 77 :Index: 14
  178. 32 :Index: 13
  179. 83 :Index: 12
  180. 94 :Index: 11
  181. 46 :Index: 10
  182. 33 :Index: 9
  183. 45 :Index: 8
  184. 55 :Index: 7
  185. 53 :Index: 6
  186. 90 :Index: 4
  187. 52 :Index: 3
  188. 81 :Index: 2
  189. 50 :Index: 1
  190.  
  191. ------------------------------
  192.  
  193. Press any key to continue . . .
  194. */
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top