Two Seperate Arrays and a search algorithm

I have a two separate files that I need to first initialize. One file has zipcodes(int) and the other has salaries (decimals). Each file has 500+ numbers. I need to write a code that when i put a number in a salary in a textbox, it will give me the salary for that zip code. For Ex. if the zip code i put in is on line 50 in the first file, then the salary will be on line 50 in the second file. My code is not written correctly.


string[] lines = new string[917];
string fileName = "AGI_FL-1-1.txt";
StreamReader file = new StreamReader(fileName);
int[] agi = new int[917];
for (int x = 0; x > lines.Length; x++)
{
lines[x] = file.ReadLine();
label2.Text = "";
agi[x] = int.Parse(Console.ReadLine());
}
file.Close();

string zip = "AGI_FL_ZipCodes-1.txt";
StreamWriter info = new StreamWriter(zip);
for (int x = 0; x < agi.Length; x++)
{
info.WriteLine("{0} is {1} AGI, lines[x], zip[x]");
}
info.Close();
}
I do not know what language you are using, but I'm sure it ain't C++.

Nevertheless, here is a program that does requested operations but the textbox:
1
2
3
#!/usr/bin/bash
FOO=$(grep -m 1 -n -x "$1" "zipcodes.txt")
[[ -n "${FOO}" ]] && head -n ${FOO%%:*} "salaries.txt" | tail -n 1

No, that ain't C++ either.
Topic archived. No new replies allowed.