Answer the question
In order to leave comments, you need to log in
C# How to parse a file and check conditions?
Need help. I can't think of an algorithm. In general, there is a text file, for example, a notepad, it contains, for example:
x1
x2&x3
x4|x1
It can contain another structure, for example:
x1
x2&x3
x4|x1x1
x5&6
x7|x1
x are users.
You need to parse the file and ask each user to write "Yes" or "No". Depending on the conditions, for example, if it's just in the line x1, then write to the user - "Yes" or "No". If in the line as above x2&x3, then write to both users, and if they both wrote "Yes", print "Yes", if someone wrote "no", then "No". And output it to the final file, for example in the form:
I sit for a long time, I can not think of. Help me please! Preferably code.
Answer the question
In order to leave comments, you need to log in
- read the first line
- see if it contains characters "&" or/and "|"
- if not, then this is one user
- if there is, then split this string by delimiters String.Split
- as a result, you get a list of users for the first line, ask them questions, get a list of answers
- apply logical operations to the answers
- append it to the first line and output
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question