Notes
Notes - notes.io |
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ANAGRAMMA
{
class Program
{
static int[] Szamlalo(string szo)
{
var db = new int[256];
foreach (var k in szo)
{
byte ascii = Convert.ToByte(k);
db[ascii]++;
}
return db;
}
static string Rendez(string szo)
{
var betuk = Szamlalo(szo);
var rendezett = "";
for (int i = 0; i < betuk.Length; i++)
{
for (int j = 0; j < betuk[i]; j++)
{
rendezett += Convert.ToChar(i);
}
}
return rendezett;
}
static bool Anagramma(string sz1, string sz2)
{
var r1 = Rendez(sz1);
var r2 = Rendez(sz2);
return r1 == r2;
}
static void Main(string[] args)
{
Console.WriteLine("1. FELADAT");
Console.Write("Adjon meg egy szót: ");
var szo = Console.ReadLine();
var betuk = Szamlalo(szo);
var kulonfele = 0;
for (int i = 0; i < betuk.Length; i++)
{
if (betuk[i] > 0)
{
kulonfele++;
Console.WriteLine("{0}: {1} db", Convert.ToChar(i), betuk[i]);
}
}
Console.WriteLine("{0} különféle karaktert találtunk", kulonfele);
Console.WriteLine("2. FELADAT");
var szotar = File.ReadAllLines("szotar.txt");
Console.WriteLine("3. FELADAT");
//using (var kimenet = Console.Out)
using (var kimenet = File.CreateText("abc.txt"))
{
foreach (var szo2 in szotar)
{
kimenet.WriteLine(Rendez(szo2));
}
}
Console.WriteLine("4. FELADAT");
Console.Write("Adjon meg egy szót: ");
var sz1 = Console.ReadLine();
Console.Write("Adjon meg még egy szót: ");
var sz2 = Console.ReadLine();
var anagramma = Anagramma(sz1, sz2);
if (anagramma)
{
Console.WriteLine("A két szó anagramma!");
}
else
{
Console.WriteLine("A két szó nem anagramma!");
}
Console.WriteLine("5. FELADAT");
Console.Write("Adjon meg egy szót: ");
sz1 = Console.ReadLine();
foreach (var sz in szotar)
{
if (Anagramma(sz1, sz))
{
Console.WriteLine(sz);
}
}
Console.ReadLine();
}
}
}
|
Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 12 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team