问ACM一题(TOJ3006)

来源:百度知道 编辑:UC知道 时间:2024/07/02 10:38:38
http://acm.tju.edu.cn/toj/showp3006.html
我的代码如下,题中提供的数据测试没问题,但还是wrong answer;请教下各位找下错误;或者直接来个AC代码也OK啊;
#include <iostream>
using namespace std;

int main(){
int bin[100][5];
int row,col;
char arry[100];
int index;
int total;
cin >> total;
for(int i = 1;i<=total;i++){
index = 0;
cin >>row >>col;
char waste;
int const ROW = row;
int const COL = col;
int ans[ROW*COL] ;
cin.get(waste);
cin.getline(arry,100);
for(int q=0;q<row;q++)for(int j=0;j<5;j++)bin[q][j]=0;
for(int j=0;arry[j];j++){
int luan = 0;
if (arry[j]==' '){
for(int c=0;c<5;c++){
bin[index][luan++]=0;

直接给你一份OK的代码得了:

#include <iostream>
#include <string>
using namespace std;
string ref[26] = {"00001","00010","00011","00100","00101","00110","00111","01000","01001","01010","01011","01100","01101","01110","01111","10000","10001","10010","10011","10100","10101","10110","10111","11000","11001","11010"};
int main()
{
int t, r, c, len, row, col, total, cc, i;
char matrix[23][23];

scanf("%d", &t);

for (cc = 1; cc <= t; cc++)
{
scanf("%d%d", &row, &col);
string str;
getline(cin, str, ' ');
getline(cin, str);
i = str.length()-1;
while (str[i] == ' '