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;
- using System.IO;
- namespace fájlbaír
- {
- class Program
- {
- static void Main(string[] args)
- {
- /*Állítsunk elő véletlenszerűúen 5 egész számot a [0,100]-ból, majd írjuk ki a számokat a képernyőre és a háttértárolóra a program BIN/DEBUG könyvtárba !*/
- int[] a = new int[5];
- Random vsz = new Random();
- for (int i = 0; i < 5; i++)
- {
- a[i] = vsz.Next(0,101);
- //képernyőre iratjuk ki
- Console.Write("{0,5}", a[i]);
- }
- string fajlnev = "szamok.txt";//fizikai fájl
- StreamWriter ir = null; //logikai fájl
- try
- {
- ir = new StreamWriter(fajlnev); //összekapcsol
- for (int i = 0; i < 5; i++)
- {
- ir.Write("{0,5}", a[i]);
- }
- ir.Close();
- }
- catch (IOException)
- {
- Console.WriteLine("I/O hiba");
- }
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement