-(void)matrix
{
int a[3][3] = {
{0, 1, 2} , /* initializers for row indexed by 0 */
{4, 5, 6} , /* initializers for row indexed by 1 */
{8, 9, 10} /* initializers for row indexed by 2 */
};
int b[3][3] = {
{0, 1, 2} , /* initializers for row indexed by 0 */
{4, 5, 6} , /* initializers for row indexed by 1 */
{8, 9, 10} /* initializers for row indexed by 2 */
};
int c[3][3] ;
for ( int i = 0; i < 3; i++ )
{
for (int j = 0; j < 3; j++ )
{
c[i][j]=0;
for(int k=0;k<=2;k++)
{
NSLog(@"a[%d][%d]= %d\n",i,k,a[i][k]);
NSLog(@"b[%d][%d]= %d\n",k,j,b[k][j]);
NSLog(@"c[%d][%d]= %d\n",i,j,c[i][j]);
NSLog(@"%d",c[i][j]+a[i][k] * b[k][j]);
c[i][j] = c[i][j]+a[i][k] * b[k][j];
NSLog(@"%d",c[i][j]);
}
}
}
for(int i=0;i<=2;i++)
{
for(int j=0;j<=2;j++)
{
NSLog(@"%d",c[i][j]);
}
}
}
Sign up here with your email
ConversionConversion EmoticonEmoticon