I have an assignment where I apply binary search and linear search is divided "hard" and both of those methods Is implemented and working. My professor wants us to test arrays with a large number of integers. He gave us a .in file which was the input in the style that he wanted and I wanted to read the file, Try to use And I am.
int main (int argc, const char * argv []) {Freipen ("Inputine", "R", staden); // & lt; ----- int n, s; Scanf ("% d% d", & amp; amp; amp; amp;; int myAr [n]; int i = 0; while (i & lt; n) {scanf ("% d", and MyAr [i]); i ++;} int myAr2 [s]; int j = 0; while (j & lt; s) {scanf ("% d", and myAr2 [j]); J ++;} ... The file starts with 2 numbers in a row, the number of elements in the list and the number of elements that you are looking for in the first list.
< P> then reads a row with all the numbers in list 1 and then the next line reads all the numbers in list 2I do not freopen () to work properly And I would like to know if there are any suggestions.
Sample input.in file:
10 2 2 4 6 7 9 10 24 26 29 33 26 35 My code will later tell me that 26 were found and were not 35. My main issue is reading the input file in the main instead of typing manually in the terminal. Please help.
I just type all the code in the input.in file to fscanf () < / Code>.
This is my code.
int j; File * FP; Fp = fopen ("input.in", "r"); While (fscanf (fp, "% d", and j)> gt; {} printf ("% d \ n", j);} Fclose (fpose); output was .
No comments:
Post a Comment