当前位置: 首页>>代码示例>>C++>>正文


C++ printResult函数代码示例

本文整理汇总了C++中printResult函数的典型用法代码示例。如果您正苦于以下问题:C++ printResult函数的具体用法?C++ printResult怎么用?C++ printResult使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了printResult函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char *argv[])
{
    if(argc != 3)
    {
        printf("Usage: %s <number> <bit index>\n", argv[0]);
        return 0;
    }

    unsigned int number = (unsigned int) atoi(argv[1]);
    int i = atoi(argv[2]);

    printf("Number: %d (0x%x)\n", number, number);
    printf("Modifying bit: %d\n", i);

    // Check if bit i is set
    unsigned int result = isBitISet(number, i);
    printResult(i, number, result);

    // Set it
    number = setBit(number, i);

    // Make sure it was set
    result = isBitISet(number, i);
    printResult(i, number, result);

    // Clear bit
    number = clearBit(number, i);

    // Make sure it was cleared
    result = isBitISet(number, i);
    printResult(i, number, result);

    return 0;
}
开发者ID:Qix-,项目名称:CS253-lab,代码行数:34,代码来源:bitmanip.c

示例2: main

int main()
{
    srand (time(NULL)); // Do not worry about this, but don't delete it
    int age = askForNumber("age");
    
    int favoriteNumbers[3];
    askForManyNumbers("your 3 favorite numbers", 3, favoriteNumbers);
    
    printf("Your age is: %d\n", age);
    printf("Your 3 favorite numbers are %d %d %d\n", favoriteNumbers[0], favoriteNumbers[1], favoriteNumbers[2]);
    
    int added = favoriteNumbers[0] + favoriteNumbers[1] + favoriteNumbers[2];
    int substracted = favoriteNumbers[0] - favoriteNumbers[1] - favoriteNumbers[2];
    int multiplied = favoriteNumbers[0] * favoriteNumbers[1] * favoriteNumbers[2];
    int divided = favoriteNumbers[0] / favoriteNumbers[1] / favoriteNumbers[2];
    
    printResult("added", added);
    printResult("substracted", substracted);
    printResult("multiplied", multiplied);
    printResult("divided", divided);
    
    int randomFavoriteNumber = favoriteNumbers[rand() % 3];
    printf("From your favorite numbers, the next lucky one is: %d\n", randomFavoriteNumber);
    printf("If you play the lottery, use the number %d\n", randomFavoriteNumber * age);
    
    return 0;
}
开发者ID:darionco,项目名称:BaseCPP,代码行数:27,代码来源:main.cpp

示例3: oneOperandOperation

/**
 * Gets a matrix from the user and performs the given operation. Then prints the result.
 * @param op The matrix operation
 * @return An error string message if the operation couldn't be done, EMPTY_STRING if the
 * operation was performed.
 */
string oneOperandOperation(MatrixOperation& op)
{
	cout << "Operation " << op._name << " requires 1 operand matrix." << endl;
	IntMatrix result;

	switch (op._id)
	{
		case TRANS:
			printMatrix(result = getMatrix());
			result = result.trans();
			printResult(MATRIX, (void*) &result);
			break;
		case TRACE:
			printMatrix(result = getMatrix());
			if (result.isSquare())
			{
				int trace = result.trace();
				printResult(NUMBER, (void*)&trace);
				break;
			}
			else
			{
				return "The matrix isn't square";
			}
		default:
			break;
	}
	return EMPTY_STRING;
}
开发者ID:shahamran,项目名称:slabcpp,代码行数:35,代码来源:IntMatrixDriver.cpp

示例4: main

int main() {
    Solution so;
    printResult(so.zigzagLevelOrder(nullptr));
    printResult(so.zigzagLevelOrder(new TreeNode(1)));
    printResult(so.zigzagLevelOrder(new TreeNode(1, new TreeNode(2, new TreeNode(3), nullptr), nullptr)));
    printResult(so.zigzagLevelOrder(new TreeNode(1, new TreeNode(2, new TreeNode(3), nullptr), new TreeNode(2))));
    printResult(so.zigzagLevelOrder(new TreeNode(3, new TreeNode(9), new TreeNode(20, new TreeNode(15), new TreeNode(7)))));
}
开发者ID:GHScan,项目名称:DailyProjects,代码行数:8,代码来源:103_BinaryTreeZigzagLevelOrderTraversal.cpp

示例5: main

int main() {
    Solution so;

    printResult(so.generateTrees(0));
    printResult(so.generateTrees(1));
    printResult(so.generateTrees(2));
    printResult(so.generateTrees(3));
    printResult(so.generateTrees(4));
}
开发者ID:GHScan,项目名称:DailyProjects,代码行数:9,代码来源:95_UniqueBinarySearchTreesII.cpp

示例6: main

int main()
{
    /// INPUT START
    freopen("input.txt", "r", stdin);
    freopen("debug.txt", "w", stderr);
    int n;
    int m;
    //cout << "input conditions:\n";
    cin >> n >> m;

    vvd a(m, vd(n));
    vd b(m);
    vc type(m);
    vc sign(n);

    for (int i = 0; i < m; ++i)
    {
        cin >> type[i];
        for (int j = 0; j < n; ++j)
            cin >> a[i][j];
        cin >> b[i];
    }

    for (int i = 0; i < n; ++i)
    {
        cin >> sign[i];
    }

    vd c(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> c[i];
    }
    /// INPUT END

    vvd dual_a;
    vd dual_b;
    vd dual_c;

    getCanonicalMatrix(a, b, c, sign, type);
    printTask(a, b, c);

    getDualProblem(a, b, c, dual_a, dual_b, dual_c);
    printTask(dual_a, dual_b, dual_c, "dual_task.txt");

    cout << "Simplex\n";
    printResult(linearProgramming::simplex(a, b, c), sign);
    cout << "\nAll vertexes\n";
    printResult(linearProgramming::allVertexesCheck(a, b, c), sign);
    cout << "\nDual problem simplex\n";
	printResult(linearProgramming::simplex(dual_a, dual_b, dual_c), sign, false);


    return 0;
}
开发者ID:AntonGitName,项目名称:MathematicalOptimizationLabs,代码行数:55,代码来源:main.cpp

示例7: main

int main(int argc, char* argv[])
{
    printResult(optimize("../sets/burma14.tsp"), 3323);
    printResult(optimize("../sets/ulysses16.tsp"), 6859);
    printResult(optimize("../sets/berlin52.tsp"), 7542);
    // assert(optimize("../sets/kroA100.tsp") == 21282);
    // assert(optimize("../sets/ch150.tsp") == 6528);
    // assert(optimize("../sets/gr202.tsp") == 40160);

    return 0;
}
开发者ID:rlee32,项目名称:2opt,代码行数:11,代码来源:TwoOpt.t.cpp

示例8: main

int main(int argc, char* argv[]) {

	if (argc < 2 ) {
		printUsage();
		exit(2);
	}

	int samplecount = atoi(argv[1]);
	int threadId = 0, i = 0, index = 0;
	double mean_counteroverhead = 0, stddev_counteroverhead = 0,\
	       mean_threadoverhead  = 0, stddev_threadoverhead = 0,\
		   mean_threadswitchoverhead= 0, stddev_threadswitchoverhead = 0;

	double threadOverheadArray[samplecount];
	double threadswitchOverheadArray[samplecount];

	pthread_t aThread;

	mean_counteroverhead = getCounteroverhead(samplecount, &stddev_counteroverhead);

	// MEASURE THE THREAD CREATION TIME
	for ( index = 0; index < samplecount; index++) {
		start = count();
		threadId = pthread_create( &aThread, NULL, threadFunc, NULL);
		pthread_join(aThread, NULL);
		threadOverheadArray[index] = end-start-mean_counteroverhead;
	}

	mean_threadoverhead = getMeanStddev(threadOverheadArray, samplecount, &stddev_threadoverhead);
//	printResult(samplecount, mean_threadoverhead, stddev_threadoverhead, "THREAD CREATION TIME");
	printResult(samplecount, getDurationinMicroSec(mean_threadoverhead),\
	                         getDurationinMicroSec(stddev_threadoverhead),\
							 "THREAD CREATION TIME");

	// MEASURE THE THREAD CONTEXT SWITCH TIME
	for ( index = 0; index < samplecount; index++) {
		threadId = pthread_create( &aThread, NULL, threadFunc, NULL);
		start = count();
		pthread_join(aThread, NULL);
		threadswitchOverheadArray[index] = end-start-mean_counteroverhead;
	}

	mean_threadswitchoverhead = getMeanStddev(threadswitchOverheadArray, samplecount, &stddev_threadswitchoverhead);
	//printResult(samplecount, mean_threadswitchoverhead, stddev_threadswitchoverhead, "THREAD CONTEXT SWITCH TIME");
	printResult(samplecount, getDurationinMicroSec(mean_threadswitchoverhead),\
	                         getDurationinMicroSec(stddev_threadswitchoverhead),\
							 "THREAD CONTEXT SWITCH TIME");

	return 0;
}
开发者ID:prabudhakshin,项目名称:OSBenchmarking,代码行数:50,代码来源:ThreadCreationSwitch.c

示例9: main

int main()
{
	program.state = 3;
	program.foo = 4;

	int ret = test(&program);

	printResult(ret);

	ret = foo(6);

	printResult(ret);

	return foo(ret);
}
开发者ID:Wallbraker,项目名称:DCPU-TCC,代码行数:15,代码来源:dcpu-testing.c

示例10: run

void	run(t_variable *_var)
{
  int		_end = 1;
  t_result	res[9];
  double	sommeCarre = 0; 
  double  max; 
  double  min;
  int		deg_lib = 0; 
  int i = 0;

  calcP(_var);
  loiBinomial(_var->p, _var);
  deg_lib = verifVal(_var, res);
  printResult(res, deg_lib);
  sommeCarre = calcCarre(res, deg_lib);
  printf ("\nloi choisie :\t\t\tB(100, %.4f)\n",_var->p);
  printf ("somme des carrés des écarts :\tX² = %.3f\n", sommeCarre);
  printf ("degrés de liberté :\t\tv = %d\n", (deg_lib - 2));
  while (i < 14 && _end != 0)
    {
      if (sommeCarre > donnees[deg_lib - 2].nb[i])
	       i++;
      else
	      {
      	  _end = 0;
      	  max = donnees[0].nb[i - 1];
      	  min = donnees[0].nb[i];
      	}
    }
  printf ("validité de l’ajustement :\t%.0f%% < P < %.0f%%\n", min, max);
}
开发者ID:chaohuilin,项目名称:Maths,代码行数:31,代码来源:main.cpp

示例11: main

int main(int argc, char *argv[]) {
	int i,j,k;
	if (argc<2) {
		fprintf(stderr, "Usage: dijkstra <filename>\n");
		fprintf(stderr, "Only supports matrix size is #define'd.\n");
	}
	//Open the adjacency matrix file
	FILE *fp;
	fp = fopen (argv[1],"r");
	/*Step 1: geting the working vertexs and assigning values*/
  	for (i=0;i<NUM_NODES;i++) {
    		for (j=0;j<NUM_NODES;j++) {
     			fscanf(fp,"%d",&k);
			AdjMatrix[i][j]= k;
    		}
  	}
	fclose(fp);
	chStart=0,chEnd=1999; //15 for small input; 1999 for large input
	if (chStart == chEnd) {
		printf("Shortest path is 0 in cost. Just stay where you are.\n");
		
	}else{
		startBarrier(&myBarrier);	/* Start barrier 	*/
		startThreads();			/* Start pthreads */	
	}
	printResult();
//}
	exit(0);
}
开发者ID:cota,项目名称:parmibench,代码行数:29,代码来源:dijkstra_parallel_squeue.c

示例12: dijksktra

int dijksktra(int graph[V][V], int source)
{
    int dist[V];
    bool sptSet[V];
    int i;
    for(i=0;i<V;i++)
    {
        dist[i]=INT_MAX; // setting the distance to be maximum value of int (or Infinity)s
        sptSet[i]=false; // all nodes are not travelled
    }
    dist[source]=0; // setting the source node's distance = 0
    for(i=0;i<V;i++)
    {
        int u=minDistance(dist,sptSet); // To get the node with minimum distance which is unvisited
        sptSet[u]=true;
        for(int v=0;v<V;v++)
        {
            if(!sptSet[v] && graph[u][v] && dist[u]!=INT_MAX && dist[u]+graph[u][v]<dist[v])
            {
                dist[v]=dist[u]+graph[u][v]; // setting the distance of a node from a node which is already visited
            }
        }
    }
    printResult(dist,0);
    return 0;
}
开发者ID:RudraNilBasu,项目名称:C-CPP-Codes,代码行数:26,代码来源:dijksktra.cpp

示例13: read

vector RetriveCore::retrive(vector<string> files)
{
	FeatureExtract fe;
	Mat retriveF;
	
	vector< vector<int> > allLenSeq = read();
	Mat allGlobal = read();
	Mat allLocal = read();
	
	vector<string> cand;
	
	int rv = files.size();
	for(int i = 0; i < rv; i ++)
	{
		retriveF = fe.tomyFeature(files[i]);
		
		
		#ifdef FILTER_BY_LENGTH
		//the minist edit distance
		double* dist = distinct(rLenSeq, allLenSeq);
		cand = filterByLenSeq(cand, dist, allLenSeq);
		#endif
		
		Mat hogFeature = localFeature(retriveF);
		Mat local_code = spectralHash(hogFeature);
		cand = filterByCode(cand, local_code, allLocal);
		
		
		printResult(files[i], cand);
		cand.clear();
		retriveF.release();
	}
	
}
开发者ID:pgxiaolianzi,项目名称:Video-Retrieve,代码行数:34,代码来源:RetriveCore.cpp

示例14: print

void Manager::Run()
{
 std::ofstream myfile;
 myfile.open("Output.txt");
 int input1, input2, targetOutput;
 for(int i=0; i<2000; ++i)
 {
  inputVals.clear();
  targetVals.clear();
  input1=rand()%2;
  input2=rand()%2;
  targetOutput=1;
  if(input1==input2) targetOutput=0;
  inputVals.push_back(input1);
  inputVals.push_back(input2);
  targetVals.push_back(targetOutput);
  myNet.feedForward(inputVals);
  myNet.backProp(targetVals);
  myNet.getResults(resultVals);
  myfile<<"Pass: "<<i<<"\n";
  std::cout<<"Input"<<std::endl;
  myfile<<"Input\n";
  print(inputVals, myfile);
  std::cout<<"TargetVals"<<std::endl;
  myfile<<"TargetVal\n";
  print(targetVals, myfile);
  std::cout<<"resultVals"<<std::endl;
  myfile<<"resultVal\n";
  printResult(resultVals, myfile);
  myfile<<"\n";
 }
 myfile.close();
}
开发者ID:sohamparekh92,项目名称:Artificial-Neural-Network-EX-OR,代码行数:33,代码来源:manager.cpp

示例15: main

// main program
int main()
{
    for (;;) {
        std::string input;

        std::getline(std::cin, input);
        if (input.empty()) break;       // empty input line exits the application 

        auto t = tokenize(input);
        try {
            auto result = parser<atomtype>::parse(t);
            for (auto &z : result) {
                // iterate over all comma-separated equations/expressions
                printResult(z);
            }

        }
        catch (parser<atomtype>::error &e) {
            auto pos = e.t.pos;
            std::cerr << std::endl << input << std::endl;
            std::cerr << std::string(pos, ' ') << "^~~~~ " << e.msg << std::endl;
        }
    }

    return 0;
}
开发者ID:ldobsik,项目名称:calculator,代码行数:27,代码来源:calculator.cpp


注:本文中的printResult函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。