Esempio n. 1
0
void main()
{
	int a[Rows][Cols];
	int b[Rows][Cols];
	int sum[Rows][Cols];
	int product[Rows][Cols];

	int i, j;

	printf("Enter the values for the first matrix..\n");
	for(i = 0; i < Rows; i++)
	{
		for(j = 0; j < Cols; j++)
		{
			scanf("%d", &a[i][j]);
		}
	}

	printf("Enter the values for the second matrix..\n");
	for(i = 0; i < Rows; i++)
	{
		for(j = 0; j < Cols; j++)
		{
			scanf("%d", &b[i][j]);
		}
	}

	AddMatrices(a, b, sum);
	MultiplyMatrices(a, b, product);

	printf("The sum matrix is......\n");
	PrintMatrix(sum);

	printf("The product matrix is......\n");
	PrintMatrix(product);

}
void
SILAttributes::SetFromNode(DataNode *parentNode)
{
    if(parentNode == 0)
        return;

    DataNode *searchNode = parentNode->GetNode("SILAttributes");
    if(searchNode == 0)
        return;

    DataNode *node;
    DataNode **children;
    if((node = searchNode->GetNode("nSets")) != 0)
        SetNSets(node->AsInt());
    if((node = searchNode->GetNode("setNames")) != 0)
        SetSetNames(node->AsStringVector());
    if((node = searchNode->GetNode("setIds")) != 0)
        SetSetIds(node->AsIntVector());
    if((node = searchNode->GetNode("wholeList")) != 0)
        SetWholeList(node->AsIntVector());
    if((node = searchNode->GetNode("nCollections")) != 0)
        SetNCollections(node->AsInt());
    if((node = searchNode->GetNode("category")) != 0)
        SetCategory(node->AsStringVector());
    if((node = searchNode->GetNode("role")) != 0)
        SetRole(node->AsIntVector());
    if((node = searchNode->GetNode("superset")) != 0)
        SetSuperset(node->AsIntVector());

    // Clear all the NamespaceAttributess if we got any.
    bool clearedNspaces = false;
    // Go through all of the children and construct a new
    // NamespaceAttributes for each one of them.
    children = searchNode->GetChildren();
    if(children != 0)
    {
        for(int i = 0; i < searchNode->GetNumChildren(); ++i)
        {
            if(children[i]->GetKey() == std::string("NamespaceAttributes"))
            {
                if (!clearedNspaces)
                {
                    ClearNspaces();
                    clearedNspaces = true;
                }
                NamespaceAttributes temp;
                temp.SetFromNode(children[i]);
                AddNspace(temp);
            }
        }
    }


    // Clear all the SILMatrixAttributess if we got any.
    bool clearedMatrices = false;
    // Go through all of the children and construct a new
    // SILMatrixAttributes for each one of them.
    children = searchNode->GetChildren();
    if(children != 0)
    {
        for(int i = 0; i < searchNode->GetNumChildren(); ++i)
        {
            if(children[i]->GetKey() == std::string("SILMatrixAttributes"))
            {
                if (!clearedMatrices)
                {
                    ClearMatrices();
                    clearedMatrices = true;
                }
                SILMatrixAttributes temp;
                temp.SetFromNode(children[i]);
                AddMatrices(temp);
            }
        }
    }


    // Clear all the SILArrayAttributess if we got any.
    bool clearedArrays = false;
    // Go through all of the children and construct a new
    // SILArrayAttributes for each one of them.
    children = searchNode->GetChildren();
    if(children != 0)
    {
        for(int i = 0; i < searchNode->GetNumChildren(); ++i)
        {
            if(children[i]->GetKey() == std::string("SILArrayAttributes"))
            {
                if (!clearedArrays)
                {
                    ClearArrays();
                    clearedArrays = true;
                }
                SILArrayAttributes temp;
                temp.SetFromNode(children[i]);
                AddArrays(temp);
            }
        }
    }

    if((node = searchNode->GetNode("order")) != 0)
        SetOrder(node->AsIntVector());
}