Example #1
0
void managements()//学生信息管理主函数
{
    struct student * incouse;
    int i,num2;
    printf("\t\t\t学生信息管理\n");
    printf("1.新增学生信息\n");
    printf("2.删除学生信息\n");
    printf("3.返回主菜单\n");
    printf("请选择(1~3):\n");
    scanf("%d",&i);
    switch(i)
    {
        case(1):
        {
            incouse=(struct student *)malloc(sizeof(struct student));
            incouse->nelen=0;
            incouse->nelenum[0]=0;
            printf("学生学号\t学生姓名\n");
            scanf("%d%s",&incouse->num2,incouse->name2);
            inserts(incouse);
            break;
        }
        case(2):
        {
            printf("请输入要删除学生的学号:\n");
            scanf("%d",&num2);
            dels(num2);
            break;
        }
        case(3):break;
    }
}
Example #2
0
vector<int> maOrderingFast(const vector<SplitEdge> &g, int s)
{
	int addOne = cG(s, g) == 0 ? 1 : 0;
	int maxNodeInd = 0;
	for (unsigned i = 0; i < g.size(); i++)
		maxNodeInd = max(g[i].end0, max(g[i].end1, maxNodeInd));
	maxNodeInd++;
	vector<bool> usedNodes(maxNodeInd, false);
	for (unsigned i = 0; i < g.size(); i++)
	{
		usedNodes[g[i].end0] = true;
		usedNodes[g[i].end1] = true;
	}
	int numNodes = 0;
	for (unsigned i = 0; i < usedNodes.size(); i++)
		numNodes += usedNodes[i];
	vector<int> ordering;
	vector<bool> inOrdering;
	for (int i = 0; i < maxNodeInd; i++)
		inOrdering.push_back(false);
	ordering.push_back(s);
	inOrdering[s] = true;

	while (ordering.size() != numNodes + addOne)
	{
		vector<int> dels(maxNodeInd, 0);
		for (unsigned i = 0; i < g.size(); i++)
		{
			if (!inOrdering[g[i].end0] && inOrdering[g[i].end1])
				dels[g[i].end0] += g[i].weight;
			if (!inOrdering[g[i].end1] && inOrdering[g[i].end0])
				dels[g[i].end1] += g[i].weight;
		}
		for (int i = 0; i < maxNodeInd; i++)
		{
			if (!usedNodes[i])
				dels[i] = -1;
		}
		int loc = -1;
		int maxDel = -1;
		for (unsigned i = 0; i < dels.size(); i++)
		{
			if (dels[i] > maxDel)
			{
				maxDel = dels[i];
				loc = i;
			}
		}
		ordering.push_back(loc);
		inOrdering[loc] = true;
	}
	//verifyMAOrdering(g, ordering);
	return ordering;
}
Example #3
0
vector<int> maOrdering(const vector<SplitEdge> &g, int s)
{
	int addOne = 0;
	if (cG(s, g) == 0)
		addOne = 1;
	int numNodes = getNumUsedNodes(g);
	int maxNodeInd = getMaxNodeInd(g);
	vector<bool> usedNodes = getUsedNodes(g);
	vector<int> ordering;
	vector<vector<pair<int, int>>> adjacency;
	adjacency.reserve(maxNodeInd);
	for (int i = 0; i < maxNodeInd; i++)
		adjacency.push_back(vector<pair<int, int>>());
	for (unsigned i = 0; i < g.size(); i++)
	{
		adjacency[g[i].end0].push_back(pair<int, int>(g[i].end1, g[i].weight));
		adjacency[g[i].end1].push_back(pair<int, int>(g[i].end0, g[i].weight));
	}
	//for each vertex in left, sum the weights of all the edges which end in ordering.
	//take the greatest of these, move from left to ordering; repeat while 
	//left isn't empty.
	vector<bool> inOrdering(maxNodeInd, false);
	ordering.push_back(s);
	inOrdering[s] = true;
	vector<int> dels(maxNodeInd, 0);
	while (ordering.size() != numNodes+addOne)
	{
		function<int(vector<pair<int,int>>)> f = [&inOrdering](vector<pair<int,int>> e)
		{
			int acc = 0;
			for (unsigned i = 0; i < e.size(); i++)
			{
				if (inOrdering[e[i].first])
					acc += e[i].second;
			}
			return acc;
		};
		transform(adjacency.begin(), adjacency.end(), dels.begin(), f);
		for (int i = 0; i < maxNodeInd; i++)
			dels[i] = inOrdering[i] || !usedNodes[i] ? -1 : dels[i];
		vector<int>::iterator maxLoc = max_element(dels.begin(), dels.end());
		int loc = std::distance(dels.begin(), maxLoc);
		ordering.push_back(loc);
		inOrdering[loc] = true;
	}
	//verifyMAOrdering(g, ordering);
	return ordering;
}
Example #4
0
void dspSummarizedBOM::sPrint()
{
  ParameterList params;
  if (!setParams(params))
    return;

  orReport report("SummarizedBOM", params);
  if (report.isValid())
    report.print();
  else
    report.reportError(this);

  QString dels("SELECT deleteBOMWorkset(<? value(\"workset_id\") ?>) AS result;");
  MetaSQLQuery delm(dels);
  q = delm.toQuery(params);
  // ignore errors since this is just cleanup of temp records
}