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


C++ std::atoi方法代码示例

本文整理汇总了C++中std::atoi方法的典型用法代码示例。如果您正苦于以下问题:C++ std::atoi方法的具体用法?C++ std::atoi怎么用?C++ std::atoi使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在std的用法示例。


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

示例1: main

int main(int argc, char * argv[]) {
   int szx = 0, szy = 0, szz = 0; /* x, y, z sizes */
   if (argc > 1) { /* single size specified */
      szx = szy = szz = atoi(argv[1]);
   }
   if (argc > 2) { /* Two sizes specified */
      szz = 0;
      szy = atoi(argv[2]);
   }
   if (argc > 3) { /* Three sizes specified */
      szz = atoi(argv[3]);
   }
   if (szx == 0) szx = 10;
   if (szy == 0) szy = 10;
   if (szz == 0) szz = 10;
   DTArray write_testing(szx,szy,szz);
   firstIndex ii; secondIndex jj; thirdIndex kk;
   /* Initialize the array with "coordinates" */
   write_testing = ii + 10*jj + 100*kk;
   /* And test the written outputs */
   write_array(write_testing,"dat_seq",0);
   write_array(write_testing,"dat_seq",1);
   write_reader(write_testing,"dat_seq",true);
   /* Nonsequenced version */
   write_array(write_testing,"dat_nsq");
   write_reader(write_testing,"dat_nsq");
   return 0;
}
开发者ID:dsteinmo,项目名称:SPINWAVE,代码行数:28,代码来源:test_write.cpp

示例2: main

int main(int argc, char* argv[])
{
  CGAL::Timer timer;
  // first param is dimension
  // second param is number of points
  int dimension = 4;
  int n = 100;
  int m = 100;

  if (argc > 1 && std::string(argv[1])== std::string("-h")) {
    std::cout<<"usage: "<<argv[0]<<" [dim] [#points] [max coords]\n";
    return 1;
  }
  if (argc > 1)  dimension = atoi(argv[1]);
  if (argc > 2)  n = atoi(argv[2]);
  if (argc > 3)  m = atoi(argv[2]);

  Delaunay_d T(dimension);
  std::list<Point_d> L;

  random_points_in_range(n,dimension,-m,m,L);

  timer.start();
  int i=0;
  std::list<Point_d>::iterator it;
  for(it = L.begin(); it!=L.end(); ++it) {
    T.insert(*it); i++;
    if (i%10==0)
      std::cout << i << " points inserted" << std::endl;
  }
  timer.stop();
  std::cout << "used time for inserts  " << timer.time() << std::endl;

  std::cout << "entering check" << std::endl;

  timer.reset();
  timer.start();
  T.is_valid();
  timer.stop();
  std::cout << "used time for sanity check  " << timer.time() << std::endl;
  

  std::cout << "entering nearest neighbor location" << std::endl;
  L.clear();
  random_points_in_range(n/10,dimension,-m,m,L);

  timer.reset();
  timer.start();
  i = 0;
  for(it = L.begin(); it!=L.end(); ++it) {
    T.nearest_neighbor(*it); i++;
    if (i%10==0) std::cout << i << " points located" << std::endl;
  }
  timer.stop();
  std::cout << "used time for location  " << timer.time() << std::endl;

  T.print_statistics();
  std::cout << "done" << std::endl;
  return 0;
}
开发者ID:mvdan,项目名称:geoc-viewer,代码行数:60,代码来源:delaunay_dd-runtime.cpp

示例3: select

Content& Content::updatePlayer(const std::string &steamID64, const std::string &category, std::unordered_map<std::string, int> stats) {
    char *errMsg;
    stringstream select(stringstream::out), upsert(stringstream::out);
    int id= Utils::hashCode(steamID64 + "-" + category);
    vector<string> newStats(stats.size());
    auto playerTable= [&stats](void *tableName, int argc, char **argv, char **colName) -> int {
        vector<string> statPairs= Utils::split(argv[3], ',');

        for(auto it= statPairs.begin(); it != statPairs.end(); it++) {
            vector<string> keyval= Utils::split(*it, '=');
            if (stats.count(keyval[0]) == 0) {
                stats[keyval[0]]= atoi(keyval[1].c_str());
            } else {
                stats[keyval[0]]+= atoi(keyval[1].c_str());
            }
        }
        return 0;
    };

    select << "select * from player where id=" << id;
    sqlite3_exec(db, select.str().c_str(), playerTable, NULL, &errMsg);

    for(auto it= stats.begin(); it != stats.end(); it++) {
        stringstream keyval(stringstream::out);
        keyval << it->first << "=" << it->second;
        newStats.push_back(keyval.str());
    }
    upsert << "replace into player (id, steamid, stats, category) values (" << 
        id << ", coalesce(( select steamid from player where id=" << id << "),\'" << steamID64 << "\'), \'" << 
        Utils::join(newStats, ',') << "\', coalesce(( select category from player where id=" << id << "),\'" << category << "\'));";
    sqlite3_exec(db, upsert.str().c_str(), NULL, NULL, &errMsg);

    return *this;
}
开发者ID:scaryghost,项目名称:KFSXTrackingServerLite,代码行数:34,代码来源:Content.cpp

示例4: GetApuesta

unsigned int GetApuesta(unsigned int &Dinero){
	echo();
	int bet;
	bool ValidBet=false;
	while(!ValidBet){
		mvprintw(20,0,"Ingrese apuesta (Si no desea seguir jugando, apueste 0): ");
		char actual;
		int TempBet;
		string getbet="";
		while((actual=getch())!=10){
			if(actual>47&&actual<58){
				getbet.push_back(actual);
			}
		}
		
		TempBet=atoi(getbet.c_str());
		if(Dinero<TempBet){
			mvprintw(23,0,"Apuesta invalida, no puede apostar una cantidad mayor a su dinero actual (%d)",Dinero);
		}else{
			bet=TempBet;
			Dinero-=bet;
			ValidBet=true;
		}	
	}
	noecho();
	return bet;

}
开发者ID:intiv,项目名称:Proyecto1,代码行数:28,代码来源:main.cpp

示例5: main

int main()
{
   int i = atoi( "2593" ); // convert string to int

   cout << "The string \"2593\" converted to int is " << i
      << "\nThe converted value minus 593 is " << i - 593 << endl;
   return 0;
} // end main
开发者ID:tecmilenio,项目名称:computacion2,代码行数:8,代码来源:fig22_23.cpp

示例6: String2Int

int String2Int (string& iStlString)
{
    // stringstream theTmpStream (iStlString);
    // int theRetInt;
    // theTmpStream >> theRetInt;
    // return theRetInt;
    return atoi (iStlString.c_str());
}
开发者ID:agapow,项目名称:mesa-revenant,代码行数:8,代码来源:StringUtils.cpp

示例7: contentLength

int WebRequest::contentLength() const
{
  std::string lenstr = envValue("CONTENT_LENGTH");

  if (lenstr.empty())
    return 0;
  else
    return atoi(lenstr.c_str());
}
开发者ID:bvanhauwaert,项目名称:wt,代码行数:9,代码来源:WebRequest.C

示例8: assign

void Version::assign(const std::string new_version) {
    string tempStr;
    vector<string> parts;
    size_t i= 0;

    while(i < new_version.size()) {
        if (new_version[i] == SEPARATOR && !tempStr.empty()) {
            parts.push_back(tempStr);
            tempStr.clear();
        } else {
            tempStr+= new_version[i];
        }
        i++;
    }
    if (!tempStr.empty()) {
        parts.push_back(tempStr);
    }

    major = atoi(parts.at(0).c_str());
    minor = atoi(parts.at(1).c_str());
    step = atoi(parts.at(2).c_str());
}
开发者ID:abdelmaged,项目名称:metawear_sampleApp_cpp,代码行数:22,代码来源:version.cpp

示例9: test_main

int test_main( int argc, char* argv[] )
{
#ifndef BOOST_NO_STDC_NAMESPACE
  using std::atoi;
#endif

  int n = 100;
  if (argc > 1) n = atoi(argv[1]);

  test<int>(n);
  test<custom>(n);

  return 0;
}
开发者ID:gijs,项目名称:hexer,代码行数:14,代码来源:minmax_element_test.cpp

示例10: main

int main(int argc, char **argv) {
    int port= atoi(argv[1]);
    ServerSocket server(port);

    cout << "Listening on port: " << port << endl;
    while(true) {
        Socket client= server.accept();
        cout << "Recieved connection from " << client.getAddress() << ":" << client.getPort() << endl;
        thread th(handler, &client);
        th.detach();
    }

    return 0;
}
开发者ID:scaryghost,项目名称:Stoughton1004Lib,代码行数:14,代码来源:webserver.cpp

示例11: fin

VoxelBuffer * VoxelBuffer::factory(const string& filename)
{
	ifstream fin(filename);
	string inputBuffer;
	VoxelBuffer * tempBuffer;

	fin >> inputBuffer;		// "DELT"
	fin >> inputBuffer;		// Delta value
	float delta = (float)atof(inputBuffer.c_str());

	fin >> inputBuffer;		// "XYZC"
	fin >> inputBuffer;
	ivec3 dimensions;
	dimensions.x = atoi(inputBuffer.c_str());
	fin >> inputBuffer;
	dimensions.y = atoi(inputBuffer.c_str());
	fin >> inputBuffer;
	dimensions.z = atoi(inputBuffer.c_str());

	tempBuffer = new VoxelBuffer(delta, dimensions);
	float tempDensity/*, tempLight*/;		// Omit reading in lights temporarily
	voxel tempVoxel;
	int voxelBufferSize = dimensions.x * dimensions.y * dimensions.z;
	tempBuffer->voxels = new voxel[voxelBufferSize];
	int i = 0;

	// Read in voxel densities (and lights...later)
	while (!fin.eof()) {
		fin >> inputBuffer;
		tempDensity = (float)atof(inputBuffer.c_str());
		tempVoxel.density = tempDensity;
		tempVoxel.light = -1.0;
		tempBuffer->voxels[i++] = tempVoxel;	// Add voxel to the 1D array
	}

	return tempBuffer;
}
开发者ID:aaronr93,项目名称:VoxelBuffer,代码行数:37,代码来源:VoxelBuffer.cpp

示例12: main

int main (int argc, char *argv[]) {
  if(argc == 1) {
    print();
  } else if(argc == 2) {
    print(argv[1]);
  } else if(argc == 3) {
    int times = atoi(argv[2]);
    if(times < 1) {
      printIllegalArg();
    } else {
      print(argv[1], times);
    }
  } else {
    printTooManyArgs();
  }
}
开发者ID:roghult,项目名称:cprog14,代码行数:16,代码来源:main.cpp

示例13: main

int main(int argc, char* argv[]){
    // First arg should be smallest power of 10 for h

    // Hardwired things:
    float x_f = sqrt(2);
    double x_d = sqrt(2); // doesn't look like sqrt works w/ long double
    string output = "/home/claire/phy480/PHY480/warmup/output.csv";

    int h_size = atoi(argv[1]);
    double *h = new double[h_size];
    for (int i=1; i<=h_size; i++){
        h[i-1] = pow(10,-i);
        //cout << h[i] << endl;
    }

    /* sizeof float: 4
     * sizeof double: 8
     * sizeof long double: 16
     */

    write_to_file(output,"h",h,h_size);
    delete [] h;

    // single precision
    float *eq1_f = new float[h_size];
    deriv_eq1(eq1_f,x_f,h,h_size);
    write_to_file(output,"eq1_f",eq1_f,h_size,true);
    delete [] eq1_f;

    float *eq2_f = new float[h_size];
    deriv_eq2(eq2_f,x_f,h,h_size);
    write_to_file(output,"eq2_f",eq2_f,h_size,true);
    delete [] eq2_f;

    // double precision
    double *eq1_d = new double[h_size];
    deriv_eq1(eq1_d,x_d,h,h_size);
    write_to_file(output,"eq1_d",eq1_d,h_size,true);
    delete [] eq1_d;

    double *eq2_d = new double[h_size];
    deriv_eq2(eq2_d,x_d,h,h_size);
    write_to_file(output,"eq2_d",eq2_d,h_size,true);
    delete [] eq2_d;

    return 0;
}
开发者ID:clairekope,项目名称:PHY480,代码行数:47,代码来源:main.cpp

示例14: Set

void CONFIGVARIABLE::Set(string newval)
{
	newval = strTrim(newval);
	
	val_i = atoi(newval.c_str());
	val_f = atof(newval.c_str());
	val_s = newval;
	
	val_b = false;
	if (val_i == 0)
		val_b = false;
	if (val_i == 1)
		val_b = true;
	if (strLCase(newval) == "true")
		val_b = true;
	if (strLCase(newval) == "false")
		val_b = false;
	if (strLCase(newval) == "on")
		val_b = true;
	if (strLCase(newval) == "off")
		val_b = false;
	
	//now process as vector information
	int pos = 0;
	int arraypos = 0;
	string::size_type nextpos = newval.find(",", pos);
	string frag;
	
	while (nextpos < /*(int)*/ newval.length() && arraypos < 3)
	{
		frag = newval.substr(pos, nextpos - pos);
		val_v[arraypos] = atof(frag.c_str());
		
		pos = nextpos+1;
		arraypos++;
		nextpos = newval.find(",", pos);
	}
	
	//don't forget the very last one
	if (arraypos < 3)
	{
		frag = newval.substr(pos, newval.length() - pos);
		val_v[arraypos] = atof(frag.c_str());
	}
}
开发者ID:VDrift,项目名称:pacejka,代码行数:45,代码来源:configfile.cpp

示例15: main

int main(int argc, char* argv[]) {
	
	int liczba{0};
	if (argc == 2) {
		char* arg = argv[1];
		liczba = atoi(arg);
	} else {
		cout << "Podaj liczbę: ";
		cin >> liczba;
	}
	
	cout << endl << "dzielniki: "; 
	
	for (int dzielnik = 1; dzielnik <= liczba/2; dzielnik++) {
		if (liczba % dzielnik == 0)  {
			cout << dzielnik << " ";
		} 
	}
	cout << liczba << endl;
	
} 
开发者ID:JuliaWalter,项目名称:uj-prog1,代码行数:21,代码来源:dzielniki.cpp


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