Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

why wrong?

Posted by kobe8936 at 2008-11-23 22:55:58 on Problem 1993
自己电脑上运行都好好的。。。高手看下
#include <iostream>
#include <string>
using namespace std;


int main()
{
	int num;
	int a[100][100],b[100][100],temp[100][100];
	bool fst;
	scanf("%d",&num);
   while (num>0)
   {
	   int maxnum;
	   fst=true;
	   int m,n,fstm,fstn,secn;
	   scanf("%d",&maxnum);
	   while (maxnum>0)
	   {
		   memset(temp,0,sizeof(temp));
		   scanf("%d %d",&m,&n);
		   if (fst==false&&(m!=fstn||m!=secn))
		   {break;
		   }
		   for (int i=0;i<m;i++)
		   {
		       for (int j=0;j<n;j++)
				 {
					 if (fst)
					 {
						 scanf("%d",&a[i][j]);
						 fstm=m;
						 fstn=n;
					     
					 }
					  else
					 {
						  scanf("%d",&b[i][j]);
						  secn=n;
					 }
				  }
		    }
		   if (fst==false)
		   {
			   for (int i=0;i<fstm;i++)
			   {
				   for (int j=0;j<secn;j++)
				   {
					   for (int k=0;k<fstn;k++)
					   {
						   temp[i][j]+=a[i][k]*b[k][j];
					   }
				   }
			   }
			   memcpy(a,temp,sizeof(temp)); 
		   }
		   fst=false;
		   maxnum--;
	   }
	   for (int i=0;i<fstm;i++)
	   {
		   for (int j=0;j<secn;j++)
		   {
			   printf("%d ",a[i][j]);
			   if (j==secn-1)
			     printf("\n");
		   }
	   }
	   printf("\r\n");
	   num--;
   }
}


Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator