[英]Comparing parallel arrays read from a text file
I have a question about using two parallel arrays. 我对使用两个并行数组有疑问。
For example, I read in 20 characters from a text file into a character array. 例如,我从一个文本文件中将20个字符读入一个字符数组。 Then I read in 20 different characters from another text file with a different character array.
然后,我从另一个具有不同字符数组的文本文件中读取了20个不同字符。
How can I compare the two and see if they match? 如何比较两者,看看它们是否匹配?
This is a separate function from the main, so this function will be passed on the arrays from main. 这是与main分开的函数,因此该函数将从main传递到数组中。
It was actually extremely easy (in case anyone else was wondering) 实际上这非常容易(以防其他人在想)
All i did was create a for loop, and inside the loop created an if statement where i called in the corresponding cells of each. 我所做的只是创建一个for循环,并在循环内部创建了一个if语句,在其中调用了每个语句的相应单元格。 If they were not equal i made a counter of how many were wrong, and displayed it at the end.
如果它们不相等,我会算出有多少错了,并在最后显示出来。
And if the questions were right do nothing. 如果问题是正确的,则什么也不做。
I don't know if i explained it super well. 我不知道我是否解释得很好。 I'm still super new to programming and i gotta say the feeling of figuring something out on your own after a lot of work feels really good :).
我仍然对编程还不是很陌生,我不得不说经过大量工作后自己弄点东西的感觉真的很不错:)。
Thanks for the replys. 感谢您的答复。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.