2018. január 22., hétfő

2018.01.22. ISMÉTLÉS : FÁJLKEZELÉS - EGYSZERŰBB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace fajlKezelesEgyszeru
{
    class Program
    {
        static int[] tomb = new int[30];
        static int[] tomb1 = new int[30];

        static void kiir()
        {
            for (int i = 0; i < tomb.Length; i++)
            {
                 Console.WriteLine(tomb[i]);
            }
        }

        static void Main(string[] args)
        {
            StreamReader sr = new StreamReader("szamok.txt");
            int i = 0;
            while (!sr.EndOfStream)
            {
                tomb[i] = Convert.ToInt32(sr.ReadLine());
                i++;
            }
            sr.Close();
            kiir();

            StreamWriter dup = new StreamWriter("dupla.txt");
            for (int j = 0; j < tomb.Length; j++)
            {
                dup.WriteLine(tomb[j] * 2);
            }
            dup.Close();

            Console.ReadLine();

            StreamWriter kis = new StreamWriter("kisebb.txt");
            for (i = 0; i < tomb.Length; i++)
            {
                if (tomb[i] < 100)
                    kis.WriteLine(tomb[i]);
            }
            kis.Close();

            Console.ReadLine();
        }
    }
}


Teszt fájl:
25
46
59
73
87
108
122
143
157
178
189
214
228
249
272
293
307
331
342
360
381
396
406
424
440
450
472
486
507
522