高手进 会Pascal 会C++ 求翻译(部分)

来源:百度知道 编辑:UC知道 时间:2024/07/07 13:03:14
x:=pos(' ',s); car.id:=copy(s,1,x-1); delete(s,1,x-1); while s[1]=' ' do delete(s,1,1);
x:=pos(' ',s); val(copy(s,1,x-1),car.x,z); delete(s,1,x-1); while s[1]=' ' do delete(s,1,1);
x:=pos(' ',s); val(copy(s,1,x-1),car.y,z); delete(s,1,x-1); while s[1]=' ' do delete(s,1,1);

val(copy(s,1,2),a,z); val(copy(s,3,2),b,z); val(copy(s,5,2),c,z);
transtime:=a*3600+b*60+c;

我关于C++的字符串不太熟悉。。。
需要把上面 从P翻译到C++ 谢谢
那么 对应P里面的eof
CPP里面是什么

/*c++中位置是从0开始的,所以1都变成0..... 起始位置均-1
再定义 char temp[1000]作为中间数据,方便你阅读
*/
x=s.pos('');car.id=s.substring(0,x-1);s.erase(0,x-1);
while (s[0]=='') s.erase(0,0);
x=s.pos('');temp=s.substring(0,x-1);car.x= atoi(temp.c_str());
s.erase(0,x-1); while (s[0]=='') s.erase(0,0);
x=s.pos('');
\\这句可以不要了temp=s.substring(0,x-1);
car.y= atoi(temp.c_str());
temp=s.substring(0,2);
while (s[0]=='') s.erase(0,0);
a=stoi(temp.c_str());
temp=s.substring(2,2);
b=stoi(temp.c_str());
temp=s.substring(4,2);
c=stoi(temp.c_str());
transtime=a*3600+b*60+c;
/*兄弟,你去买一本c++ primer plus吧,我也是学p的,刚用18小时学完了c++基本知识(集训真累啊),书对你很有用的。
现在我用百度搜索都不会恩回车键了,直接就恩F9了......
*/

/*
eof就是eof 判断语句为 (getch(&变量名)!=eof)
兄弟,再买一本《the c programming language》《c程序设计语言》也很好!很有帮助!

*/

delete(s,1,1) : s.erase(1,1)
copy(s,3,2) : s.subst