高手帮忙下 谢谢

zl276259549 2008-12-03 09:55:41
//==============================
//f0615.cpp
//剩余串排列
//==============================
#include<iostream>
#include<fstream>
#include<algorithm>
#include<string>
using namespace std;
//------------------------------
int main()
{
ifstream in("remainder.txt");
for(string s,t,u;in>>s>>t;u="")
{
sort(s.begin(),s.end());
sort(t.begin(),t.end());
set_difference(s.begin(),s.end(),t.begin(),t.end(),back_inserter(u));
cout<<u<<endl;
}
}
书中的一个例子 但是编译提示没有返回值 高手帮忙看看哪里有问题 谢谢
...全文
113 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
「已注销」 2009-06-02
  • 打赏
  • 举报
回复
为什么我的还不行啊,还是运行不了啊
deerwin1986 2008-12-03
  • 打赏
  • 举报
回复
没有错误return 0 有错误1 或者其他值 这样比较标准
hurry281 2008-12-03
  • 打赏
  • 举报
回复
main()
无返回值
int main(void)
{
return 1;
}
zxianrong 2008-12-03
  • 打赏
  • 举报
回复
//f0615.cpp
//剩余串排列
//==============================
#pragma warning (disable:4786)
#include <iostream>
#include <fstream>
#include <algorithm>
#include <set>
#include <string>
using namespace std;
//------------------------------
int main()
{
ifstream in("remainder.txt");
string sc[10];
for(string s,t,u;in>>s>>t;u="")
{
sort(s.begin(),s.end());
sort(t.begin(),t.end());
string * end= set_difference(s.begin(),s.end(),t.begin(),t.end(),sc);
for(string * p=sc;p!=end;p++)
cout<<*p<<" ";
}
return 0;
}
zl276259549 2008-12-03
  • 打赏
  • 举报
回复
我的 txt 文件中的是 这几个字符
computer program
Write program
zl276259549 2008-12-03
  • 打赏
  • 举报
回复
尝试了 你们的方法 可是又有错误
error C2039: 'push_back' : is not a member of 'basic_string<char,struct std::char_traits<char>,class std::allocator<char> >'
toadzw 2008-12-03
  • 打赏
  • 举报
回复
int main()
{
ifstream in("remainder.txt");
for(string s,t,u;in>>s>>t;u="")
{
sort(s.begin(),s.end());
sort(t.begin(),t.end());
set_difference(s.begin(),s.end(),t.begin(),t.end(),back_inserter(u));
cout < <u < <endl;
}

return 1
}
zxianrong 2008-12-03
  • 打赏
  • 举报
回复
对啊 ,不过你也可以把int main 改成void main
bill830711 2008-12-03
  • 打赏
  • 举报
回复
main函数声明的返回值为int
所以在main函数返回前需要一个 return语句
一般如果正常执行完,return 0就可以了


int main()
{
ifstream in("remainder.txt");
for(string s,t,u;in>>s>>t;u="")
{
sort(s.begin(),s.end());
sort(t.begin(),t.end());
set_difference(s.begin(),s.end(),t.begin(),t.end(),back_inserter(u));
cout < <u < <endl;
}
return 0 ; // 此处加上return
}

wuyu637 2008-12-03
  • 打赏
  • 举报
回复
int main()
{
ifstream in("remainder.txt");
for(string s,t,u;in>>s>>t;u="")
{
sort(s.begin(),s.end());
sort(t.begin(),t.end());
set_difference(s.begin(),s.end(),t.begin(),t.end(),back_inserter(u));
cout < <u < <endl;
}

return 1;===================>加上这句
}

65,211

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧