2022.01.12. Fájlkezelés gyakorlás

 Írtunk önállóan egy fájlkezelést, ami egy 100 elemű tömböt kezel. Kiírtuk fájlba 100-szor a 100 elemű tömböt.


using System;
using System.IO;



namespace _2022._01._12_
{
  class Program
  {
    static int[] tomb1 = new int[100];
    static void kiir()
    {
      for (int i = 0; i < tomb1.Length; i++)
      {
        Console.WriteLine(tomb1[i]);

      }

    }
    static void Main(string[] args)
    {

      StreamReader sr = new StreamReader("szamok.txt");
      int i = 0;
      while (!sr.EndOfStream)
      {
        tomb1[i] = Convert.ToInt32(sr.ReadLine());
        i++;

      }

      sr.Close();

      kiir();
      Console.ReadLine();

      StreamWriter sw = new StreamWriter("negyzetgyok.txt");
      i = 0;
      while (i < tomb1.Length)
      {

        sw.WriteLine(Math.Sqrt(tomb1[i]));
        i++;
      }
      sw.Close();
      Console.ReadLine();

      StreamWriter sw1 = new StreamWriter("nagy.txt");
      i = 0;
      int j = 0;
      int szamlalo = 1;
      while (i < 100)
      {
        j = 0;
        while (j < 100)
        {
          sw1.WriteLine("{0}. {1}", szamlalo, tomb1[j]);
          szamlalo++;
          j++;
        }
        i++;
      }
      sw1.Close();

    }
  }
}


2023.04.26. Javító feladatsor