64,648
社区成员
发帖
与我相关
我的任务
分享
#include <string>
#include <iostream>
int main(int argc, char* argv[])
{
string str("中科院一个u盘买了6428元-----------------------------------------鼓掌");
unsigned len = str.length();
const unsigned line = 10;
string tmp;
unsigned times = 0;
unsigned timess = len % line;
if(timess == 0)
{
times = len / line;
}
else
{
timess = len / line + 1;
}
string tmp;
int currPos = 0;
for(unsigned i = 0; i < times ; ++i)
{
tmp = str.substr(currPos, lineNume);
currPos += lineNume;
cout<< tmp <<endl;
tmp.clear();
}
getchar();
return 0;
}
#include <string>
#include <iostream>
using namespace std;
//看来LZ确实加晕了,这里的(打成中文的了
int main(int argc, char* argv[])
{
string str("中科研究院买了一个128M的惠普内存条6428------------------鼓掌");
unsigned len = str.length();
const unsigned line = 10;
string tmp;
unsigned times = 0;
unsigned timess = len % line;
if(timess == 0)
{
times = len / line;
}
else
{
timess = len / line + 1;
}
// string tmp;//和上边的重定义了
int currPos = 0;
for(unsigned i = 0; i < times ; ++i)
{
tmp = str.substr(currPos, line);
currPos += line;//少了个分号
cout<< tmp <<endl;
tmp.clear();//不知道是不是我的编译问题,提示是找不到这个成员函数
}
getchar();
return 0;
}
#include <string>
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
string str("中科研究院买了一个128M的惠普内存条6428------------------鼓掌");
unsigned len = str.length();
const unsigned line = 10;
string tmp;
unsigned times = 0;
unsigned timess = len % line;
if(timess == 0)
{ times = len / line; }
else
{ timess = len / line + 1; }
string tmp;
int currPos = 0;
for(unsigned i = 0; i < times ; ++i)
{
tmp = str.substr(currPos, line);
currPos += line
cout<< tmp <<endl; tmp.clear();
}
getchar();
return 0;
}
#include <string>
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
string str("中科研究院买了一个128M的惠普内存条6428------------------鼓掌");
unsigned len = str.length();
const unsigned line = 10;
string tmp;
unsigned times = 0;
unsigned timess = len % line;
if(timess == 0) { times = len / line; }
else { timess = len / line + 1; }
string tmp;
int currPos = 0;
for(unsigned i = 0; i < times ; ++i)
{
tmp = str.substr(currPos, lineNume);
currPos += lineNume;
cout<< tmp <<endl; tmp.clear();
}
getchar();
return 0;
}