Az alábbi letöltési lehetőségek közül választhatsz: (
segítség)
Típus: text/plain
Tartalmaz szöveget
Karakterkódolás: utf-8
Méret: 3 KB
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace zaszlo
{
class Diff
{
public int line;
public int start, end;
public char ch;
public Diff(int line, int start, int end, char ch)
{
this.line = line+1;
this.start = start+1;
this.end = end+1;
this.ch = ch;
}
internal void print(StreamWriter outs)
{
outs.WriteLine("{0} {1} {2} {3}", line, start, end, ch);
}
}
class zaszlo
{
private int n, m;
private char[] last;
private char[] last_;
private List<Diff> list = new List<Diff>();
public zaszlo()
{
StreamReader ins = new StreamReader("zaszlo.be");
string[] line = ins.ReadLine().Split(' ');
m = int.Parse(line[0]);
n = int.Parse(line[1]);
last = new char[n];
last_ = new char[n];
for( int i=0; i<n; i++ ) {
last[i] = '0';
}
int diff_s = -1;
char ch = 'A';
for (int j = 0; j < m; j++)
{
diff_s = -1;
line = ins.ReadLine().Split(' ');
for( int i = 0; i<n; i++ )
{
last_[i] = line[i][0];
if (last[i] != last_[i])
{
if (diff_s == -1)
{
diff_s = i;
ch = last_[i];
}
else
{
if (ch != last_[i])
{
list.Add(new Diff(j, diff_s, i-1, ch));
diff_s = i;
ch = last_[i];
}
}
}
else if(diff_s != -1)
{
list.Add(new Diff(j, diff_s, i-1, ch));
diff_s = -1;
}
}
if (diff_s != -1)
{
list.Add( new Diff( j, diff_s, n-1, ch ) );
}
for (int i = 0; i < n; i++)
{
last[i] = last_[i];
}
}
printOut();
}
private void printOut()
{
StreamWriter outs = new StreamWriter("zaszlo.ki");
outs.WriteLine( "{0} {1}", m, n );
for (int i = 0; i < list.Count; i++)
{
list[i].print( outs );
}
outs.Close();
}
static void Main(string[] args)
{
new zaszlo();
}
}
}