コード例 #1
0
ファイル: gaussian.c プロジェクト: loccs-faker/calculators
void gaussianText(char *valueText, int doFactorization)
{
  enum eExprErr rc;
#ifndef __EMSCRIPTEN__
  groupLen = 6;
#endif
  rc = ComputeGaussianExpression(valueText, value);
  output[0] = '2';
  ptrOutput = &output[1];
  if (rc == EXPR_OK)
  {
    CopyBigInt(&ReValue, &value[0]);
    CopyBigInt(&ImValue, &value[1]);
    if (doFactorization != '0')
    {
      w(lang ? "<p>Factores de " : "<p>Factors of ");
    }
    else
    {
      w(lang ? "<p>El valor es " : "<p>Value is equal to ");
    }
    showNumber(&ReValue, &ImValue);
    if (doFactorization != '0')
    {
      GaussianFactorization();
    }
  }
  if (rc == EXPR_OK)
  {
    showElapsedTime(&ptrOutput);
  }
  else
  {
    textError(ptrOutput, rc);
    ptrOutput = output + strlen(output);
  }
  strcat(ptrOutput, lang ? "<p>" COPYRIGHT_SPANISH "</p>" :
                           "<p>" COPYRIGHT_ENGLISH "</p>");
}
コード例 #2
0
ファイル: main_TT2GIS.cpp プロジェクト: DeaDiana/TestTask2GIS
int main(int argc, char * argv[]) {
	if (1 == argc) {
		std::cout << NFLGS_MSG << std::endl;
		return 0;
	}
	long start_time = 0;
	try {
		std::map <ArgumentsFlags, std::string> paramters = parseCommandLineIntoTheMapOfParameters(argc, argv);
		if (paramters.empty()) {
			std::cout << NFLGS_MSG << std::endl;
			return 0;
		}
		std::map <ArgumentsFlags, std::string>::iterator it_sub = paramters.begin();
		start_time = clock();
		for( std::map <ArgumentsFlags, std::string>::iterator it = paramters.begin(); 
			 it != paramters.end(); 
			 it++ ) {
			switch (it->first) {
				case FILE_FLAG:
					it_sub = paramters.find(MODE_FLAG);
					if (paramters.end() == it_sub) {
						std::cerr << ERROR_MSG_NEPARAMS << std::endl;
						showElapsedTime(start_time);
						return -1;
					}
					if (FLAG_VALUE_WORDS == it_sub->second) {
						it_sub = paramters.find(VALUE_FLAG);
						if (paramters.end() != it_sub) {
							std::cout << LINE << FOR_COUNTER_RESPONSE << WordCounter::countWords(paramters.at(FILE_FLAG), it_sub->second) << std::endl;
							showElapsedTime(start_time);
							showInfo(paramters.at(FILE_FLAG), it_sub->second);
							return 0;
						} else {
							std::cerr << ERROR_MSG_NEPARAMS << std::endl;
							showElapsedTime(start_time);
							return -1;
						}
					}
					if (FLAG_VALUE_CHKSUM == it_sub->second) {
						std::cout << LINE << FOR_CHECKER_RESPONSE << std::hex << Checker::countCheckSum(paramters.at(FILE_FLAG)) << std::endl;
						showElapsedTime(start_time);
						showInfo(paramters.at(FILE_FLAG));
						return 0;
					}
					std::cerr << ERROR_MSG_NEPARAMS << std::endl;
					showElapsedTime(start_time);
					return -1;
				case HELP_FLAG:
					Helper::printHelp();
					showElapsedTime(start_time);
					return 0;
				default:
					break;
			}
		}
	} catch (ParseCmdLineException & e) {
		std::cerr << e.getMessage() <<std::endl;
	} catch (WordCounterException & e) {
		std::cerr << e.getMessage() <<std::endl;
	} catch (CheckerException & e) {
		std::cerr << e.getMessage() <<std::endl;
	} catch (std::exception & e) {
		std::cerr << ERROR_MSG_COMMON << std::endl << e.what() << std::endl;
	}
	showElapsedTime(start_time);
	return 0;
}