zoj 1949 Error Correction

原创 2012年03月31日 12:35:38
#include "iostream"
#include "memory.h"
using namespace std;

int matrix[110][110], rowsum[110], columnsum[110], rowans[110], columnans[110];

int main()
{
	int n, i, j, rowcount, columncount;
	while (cin >> n && n)
	{
		memset(rowsum, 0, sizeof(rowsum));
		memset(columnsum, 0, sizeof(columnsum));
		memset(rowans, 0, sizeof(rowans));
		memset(columnans, 0, sizeof(columnans));
		rowcount = columncount = 0;
		for (i = 0; i < n; i++)
			for (j = 0; j < n; j++)
				cin >> matrix[i][j];
		for (i = 0; i < n; i++)
			for (j = 0; j < n; j++)
			{
				rowsum[i] += matrix[i][j];
				columnsum[i] += matrix[j][i];
			}
		for (i = 0; i < n; i++)
		{
			if (rowsum[i] % 2 != 0)
				rowans[i] = 1;
			if (columnsum[i] % 2 != 0)
				columnans[i] = 1;
		}
		for (i = 0; i < n; i++)
		{
			if (rowans[i] == 1)
				rowcount++;
			if (columnans[i] == 1)
				columncount++;
		}
		if (rowcount == 0 && columncount == 0)
			cout << "OK" << endl;
		else if (rowcount == 1 && columncount == 1)
		{
			int temp1, temp2;
			for (i = 0; i < n; i++)
				if (rowans[i] == 1)
			        temp1 = i;
			for (i = 0; i < n; i++)
				if (columnans[i] == 1)
					temp2 = i;
					 cout << "Change bit (" << temp1+ 1<< ","<< temp2 + 1 << ")" << endl;
		}
		else
			cout << "Corrupt" << endl;
	}
}

zoj_1949 Error Correction

A boolean matrix has the parity property when each row and each column has an even sum, i.e. contain...

zoj 1949 Error Correction

/* 若每行每列的和都是偶数,输出OK; 若能修改一个符合要求,输出其坐标; 否则...... */ #include #include int map[110][110],r,c; int m...

zoj1949-------------Error Correction

A boolean matrix has the parity property when each row and each column has an even sum, i.e. contain...
  • zzukun
  • zzukun
  • 2012年08月18日 16:21
  • 278

Error Correction(zoj 1949)

Description A boolean matrix has the parity property when each row and each column has an even sum,...

ZOJ-1949

import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner ...
  • xhldtc
  • xhldtc
  • 2013年12月21日 17:47
  • 259

Error Correction Coding _ Tood.pdf

  • 2016年01月30日 22:13
  • 45.07MB
  • 下载

Error Detection And Correction

Communication channels have a range of characteristics. Some channels, like optical fiber in telecom...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:zoj 1949 Error Correction
举报原因:
原因补充:

(最多只允许输入30个字)