| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 749 人关注过本帖
标题:[菜鸟求助]瞧一瞧,看一看啊,,菜鸟又有新问题啦,答对没奖啦,,答错打屁屁啦,,
取消只看楼主 加入收藏
dlcdavid
Rank: 3Rank: 3
来 自:成都
等 级:新手上路
威 望:6
帖 子:193
专家分:0
注 册:2005-12-23
收藏
 问题点数:0 回复次数:2 
[菜鸟求助]瞧一瞧,看一看啊,,菜鸟又有新问题啦,答对没奖啦,,答错打屁屁啦,,

#include <fstream>
#include <vector>
#include <list>
#include <algorithm>
这几个文件里有什么东西啊???

using namespace std;
拿来做什么啊???

vector<float> xxxxxxxxx
这是什么啊??有什么用啊???
最后请有空的大侠帮个忙,,,,翻译一下嘛,,,,,算24的,,,,,为什么他里面有些输出用的printf...输出的结果小数点后面有8个0,是不是把%f删了就行了???
char charnumber4[20] = "";
sprintf(charnumber4, "%f", num4);
string number4=charnumber4;
可以说一下嘛,最好重新帮小弟改一下,,,有更好看的这个程序发上来更好啊...
上面的问题都来自这个程序
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
using namespace std;

int result_set_generation(float, float, float, float);

int main()
{
float num1, num2, num3, num4;

cout << "enter number1 ";
cin >> num1;
cout << "enter number2 ";
cin >> num2;
cout << "enter number3 ";
cin >> num3;
cout << "enter number4 ";
cin >> num4;

result_set_generation(num1, num2, num3, num4);
result_set_generation(num1, num2, num4, num3);
result_set_generation(num1, num3, num2, num4);
result_set_generation(num1, num3, num4, num2);
result_set_generation(num1, num4, num3, num2);
result_set_generation(num1, num4, num2, num3);

result_set_generation(num2, num3, num1, num4);
result_set_generation(num2, num3, num4, num1);
result_set_generation(num2, num4, num1, num3);
result_set_generation(num2, num4, num3, num1);

result_set_generation(num3, num4, num1, num2);
result_set_generation(num3, num4, num2, num1);

return 0;
}

int result_set_generation(float num1, float num2, float num3, float num4)
{
vector<float> first_result;
vector<float> second_result;
vector<float> third_result;
vector<string> firstexp;
vector<string> secondexp;
vector<string> thirdexp;

string expression;

float first1, first2, first3, first4, first5, first6;
float second;
float third;

first1=num1+num2;
first2=num1-num2;
first3=num2-num1;
first4=num1*num2;
first5=num1/num2;
first6=num2/num1;

char charnumber1[20] = "";
sprintf(charnumber1, "%f", num1);
string number1=charnumber1;
char charnumber2[20] = "";
sprintf(charnumber2, "%f", num2);
string number2=charnumber2;
char charnumber3[20] = "";
sprintf(charnumber3, "%f", num3);
string number3=charnumber3;
char charnumber4[20] = "";
sprintf(charnumber4, "%f", num4);
string number4=charnumber4;

expression=number1+"+"+number2;
firstexp.push_back(expression);
expression=number1+"-"+number2;
firstexp.push_back(expression);
expression=number2+"-"+number1;
firstexp.push_back(expression);
expression=number1+"*"+number2;
firstexp.push_back(expression);
expression=number1+"/"+number2;
firstexp.push_back(expression);
expression=number2+"/"+number1;
firstexp.push_back(expression);

first_result.push_back(first1);
first_result.push_back(first2);
first_result.push_back(first3);
first_result.push_back(first4);
first_result.push_back(first5);
first_result.push_back(first6);


for (int i=0; i<6; i++)
{
second=first_result[i]+num3;
second_result.push_back(second);
expression="("+firstexp[i]+")"+"+"+number3;
secondexp.push_back(expression);

second=first_result[i]-num3;
second_result.push_back(second);
expression="("+firstexp[i]+")"+"-"+number3;
secondexp.push_back(expression);

second=num3-first_result[i];
second_result.push_back(second);
expression=number3+"-"+"("+firstexp[i]+")";
secondexp.push_back(expression);

second=first_result[i]*num3;
second_result.push_back(second);
expression="("+firstexp[i]+")"+"*"+number3;
secondexp.push_back(expression);

second=first_result[i]/num3;
second_result.push_back(second);
expression="("+firstexp[i]+")"+"/"+number3;
secondexp.push_back(expression);

second=num3/first_result[i];
second_result.push_back(second);
expression=number3+"/"+"("+firstexp[i]+")";
secondexp.push_back(expression);
}

for (i=0; i<36; i++)
{
third=second_result[i]+num4;
third_result.push_back(third);
expression="("+secondexp[i]+")"+"+"+number4;
thirdexp.push_back(expression);

third=second_result[i]-num4;
third_result.push_back(third);
expression="("+secondexp[i]+")"+"-"+number4;
thirdexp.push_back(expression);

third=num4-second_result[i];
third_result.push_back(third);
expression=number4+"-"+"("+secondexp[i]+")";
thirdexp.push_back(expression);

third=second_result[i]*num4;
third_result.push_back(third);
expression="("+secondexp[i]+")"+"*"+number4;
thirdexp.push_back(expression);

third=second_result[i]/num4;
third_result.push_back(third);
expression="("+secondexp[i]+")"+"/"+number4;
thirdexp.push_back(expression);

third=num4/second_result[i];
third_result.push_back(third);
expression=number4+"/"+"("+secondexp[i]+")";
thirdexp.push_back(expression);
}

vector<float>::iterator p = third_result.begin();
vector<string>::iterator j=thirdexp.begin();
while(p!=third_result.end())
{
if(*p==24)
cout<<*j<<endl;
p++;
j++;
}

return 0;
};


他警告:
--------------------Configuration: Cpp1 - Win32 Debug--------------------
Compiling...
Cpp1.cpp
C:\Documents and Settings\user_child\桌面\算24的C程序\新建文件夹\Cpp1.cpp(175) : warning C4786: 'std::reverse_iterator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const *,std::basic_string<char,std::char_traits<char>,std::al
locator<char> >,std::basic_string<char,std::char_traits<char>,std::allocator<char> > const &,std::basic_string<char,std::char_traits<char>,std::allocator<char> > const *,int>' : identifier was truncated to '255' characters in the debug information
C:\Documents and Settings\user_child\桌面\算24的C程序\新建文件夹\Cpp1.cpp(175) : warning C4786: 'std::reverse_iterator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > *,std::basic_string<char,std::char_traits<char>,std::allocato
r<char> >,std::basic_string<char,std::char_traits<char>,std::allocator<char> > &,std::basic_string<char,std::char_traits<char>,std::allocator<char> > *,int>' : identifier was truncated to '255' characters in the debug information
d:\download\vc98\include\vector(39) : warning C4786: 'std::vector<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >::vector<std::basic_string<
char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >' : identifier was truncated to '255' characters in the debug information
d:\download\vc98\include\vector(60) : warning C4786: 'std::vector<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >::~vector<std::basic_string
<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >' : identifier was truncated to '255' characters in the debug information
Linking...

Cpp1.exe - 0 error(s), 4 warning(s)

搜索更多相关主题的帖子: 打屁 include vector 答对 
2005-12-26 21:56
dlcdavid
Rank: 3Rank: 3
来 自:成都
等 级:新手上路
威 望:6
帖 子:193
专家分:0
注 册:2005-12-23
收藏
得分:0 
申明,,这不是我的程序,,呵呵,,不然我哪来的问题嘛
我就爱拿现成的程序来分析,,
我觉得比看书有用

为了C++,我放弃了课本
为了高考,我又放弃了C++
现在而今眼目下,我能做什么?www.
2005-12-28 22:24
dlcdavid
Rank: 3Rank: 3
来 自:成都
等 级:新手上路
威 望:6
帖 子:193
专家分:0
注 册:2005-12-23
收藏
得分:0 
stl是什么哦??????嘎嘎,,,

为了C++,我放弃了课本
为了高考,我又放弃了C++
现在而今眼目下,我能做什么?www.
2005-12-30 23:03
快速回复:[菜鸟求助]瞧一瞧,看一看啊,,菜鸟又有新问题啦,答对没奖啦,,答错打屁屁 ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017064 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved