- Write a program that reads a text file and prints on the console its odd lines.
- Write a program that concatenates two text files into another text file.
- Write a program that reads a text file and inserts line numbers in front of each of its lines. The result should be written to another text file.
- Write a program that compares two text files line by line and prints the number of lines that are the same and the number of lines that are different. Assume the files have equal number of lines.
- Write a program that reads a text file containing a square matrix of numbers and finds in the matrix an area of size 2x2 with a maximal sum of its elements. The first line in the input file contains the size of matrix
N
. Each of the next N lines contain N numbers separated by space. The output should be a single number in a separate text file. Example:
N = 4 | |||
---|---|---|---|
2 | 3 | 3 | 4 |
0 | 2 | 3 | 4 |
3 | 7 | 1 | 2 |
4 | 3 | 3 | 2 |
Ivan | George |
Peter | Ivan |
Maria | Maria |
George | Peter |
```xml
<?xml version="1.0"?>
<student>
<name>Pesho</name>
<age>21</age>
<interests count="3">
<interest>Games</interest>
<interest>C#</interest>
<interest>Java</interest>
</interests>
</student>
```
- Write a program that deletes from a text file all words that start with the prefix "test". Words contain only the symbols
0...9, a...z, A...Z, _
. - Write a program that removes from a text file all words listed in given another text file. Handle all possible exceptions in your methods.
- Write a program that reads a list of words from a file
words.txt
and finds how many times each of the words is contained in another filetest.txt
. The result should be written in the fileresult.txt
and the words should be sorted by the number of their occurrences in descending order. Handle all possible exceptions in your methods.