Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Graphs
- {
- class Program
- {
- static void Main(string[] args)
- {
- //read file by line
- String line;
- System.IO.StreamReader file = new System.IO.StreamReader(@"D:\users\boris\documents\visual studio 2013\Projects\Graphs\Graphs\input.txt");
- String header_line = line = file.ReadLine();//read first line
- String[] segments = header_line.Split(' ');
- int tops = Convert.ToInt32(line.Split(' ')[0]);
- int sides = Convert.ToInt32(line.Split(' ')[1]);
- int[,] matrix = new int[tops, tops];
- for (int i = 0; i < matrix.GetLength(0); i++)
- {
- for (int j = 0; j < matrix.GetLength(1); j++)
- {
- matrix[i, j] = 0;
- }
- }
- while ((line = file.ReadLine()) != null)
- {
- int i = Convert.ToInt32(line.Split(' ')[0]) - 1;
- int j = Convert.ToInt32(line.Split(' ')[1]) - 1;
- matrix[i, j] = 1;
- }
- line = "";
- using (System.IO.StreamWriter outputfile = new System.IO.StreamWriter(@"D:\users\boris\documents\visual studio 2013\Projects\Graphs\Graphs\output.txt"))
- {
- for (int i = 0; i < matrix.GetLength(0); i++)
- {
- for (int j = 0; j < matrix.GetLength(1); j++)
- {
- line = line + Convert.ToString(matrix[i, j]) + " ";
- }
- outputfile.WriteLine(line);
- line = "";
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement