/************************************************ Grundlegende Algorithmen mit Java, http://algorithmen-und-problemloesungen.de/ Copyright @2007-2008 by Doina Logofatu in C#: Michael Gärtner ************************************************/ using System; using System.IO; namespace Logofatu { class P4Tart2 { private static String FileInputName = "torte.in"; private static String FileOutputName = "torte.out"; static void Main(string[] args) { StreamReader sr = null; StreamWriter sw = null; try { sr = new StreamReader(FileInputName); sw = new StreamWriter(FileOutputName); while ( !sr.EndOfStream ) { int n = int.Parse(sr.ReadLine()); sw.Write("{0,4:d} Schnitte -> {1,7:d} Stuecke!\n", n, 1 + n*(n+1)/2); } } catch ( IOException ex ) { Console.WriteLine("Fehler bei der Dateiverarbeitung!\n" + ex); } finally { if ( sr != null ) { sr.Close(); } if ( sw != null ) { sw.Close(); } } } } }