C# :: Aufgabe #301
9 Lösungen
Das kleine Einmaleins
Anfänger - C#
von DragStar
- 06.04.2020 um 08:32 Uhr
Erstellen Sie ein Programm, welches das kleine Einmaleins in der Form
1 2 3 4 5 6 7 8 9 10
2 4 6 8 10 12 14 16 18 20
3 ...
.
.
.
10 20 30 40 50 60 70 80 90 100
ausgibt.
1 2 3 4 5 6 7 8 9 10
2 4 6 8 10 12 14 16 18 20
3 ...
.
.
.
10 20 30 40 50 60 70 80 90 100
ausgibt.
Lösungen:
NET Core 3.x
C#-Code
using static System.Console;
namespace CS_Aufgabe_301_Einmaleins
{
class Program
{
static void Main(string[] args)
{
Write($" |");
for (int i = 1; i < 11; i++)
Write($"{i,4}");
WriteLine();
WriteLine(new string('-', 46));
for (int k = 1; k < 11; k++)
{
Write($"{k,4} |");
for (int j = 1; j < 11; j++)
Write($"{k*j, 4}");
WriteLine();
}
}
}
}
using System;
namespace Einmaleins
{
class Program
{
static void Main()
{
for(int n = 1; n <= 10; n++)
{
for (int i = 1; i <= 10; i++)
{
Console.Write(n * i + " ");
}
Console.Write(Environment.NewLine);
}
Console.ReadLine();
}
}
}
using System;
namespace Einmaleins
{
class Program
{
static void Main(string[] args)
{
for (int i = 1; i <= 10; i++)
{
Console.Write(i + "\t");
for (int k = 1; k <= 10; k++)
{
Console.Write(i * k + "\t");
}
Console.WriteLine();
}
Console.ReadKey();
}
}
}
Mein Lösungsvorschlag:
C#-Code
using System;
namespace Aufgabe_301
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hallo!,\n Dieses Programm gibt die Zahlen des kleinen Einmaleins aus! \n\n" );
for (int i = 1; i <= 10; i++)
{
for (int j = 1; j <=10 ; j++)
{
Console.Write(i * j+" ");
}
Console.WriteLine();
}
Console.ReadKey();
}
}
}
using System;
namespace DasKleineEinMalEins
{
class Program
{
static void Main(string[] args)
{
int reihe;
for (reihe = 1; reihe <= 10; reihe++)
{
for (int i = 1; i <= 10; i++)
{
Console.Write(i * reihe + " ");
}
Console.WriteLine();
}
}
}
}
using System;
namespace kleines_1Mal1
{
class Program
{
static void Main(string[] args)
{
Console.ForegroundColor = ConsoleColor.Blue;
Console.WriteLine("\n ---------- Das kleine 1 Mal 1 ----------\n");
Console.ForegroundColor = ConsoleColor.White;
for (int a = 1; a < 11; a++)
{
for (int x = 1; x < 11; x++)
{
Console.Write(x * a + " ");
}
Console.WriteLine();
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Einmaleins
{
class Program
{
static void Main(string[] args)
{
int i, k;
for (i = 1; i <= 10; i++)
{
for (k = 1; k < 11; k++)
{
Console.Write(i * k + " ");
}
}
Console.Read();
}
}
}
Ich hab die Form und die Ausgabe ein bisschen verändert:
C#-Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Einmaleins
{
class Program
{
static void Main(string[] args)
{
int i, k;
Console.WriteLine($" 1\t 2\t 3\t 4\t 5\t 6\t 7\t 8\t 9\t 10");
for (i = 1; i <= 10; i++)
{
for (k = 1; k < 11; k++)
{
Console.Write($"{k}*{i}={i * k}\t");
}
Console.WriteLine("");
}
Console.Read();
}
}
}using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Übungen_Aufgaben_zu_301
{
class Program
{
static void Main(string[] args)
{
int G, k;
for (G = 1; G <= 10; G++)
{
for (k = 1; k < 11; k++)
{
Console.WriteLine(" Das Ergebnis ist = " + G * k );
}
Console.Read();
}
}
}
}
