参数传递问题
我编了个函数传递四个参数,我想把一个由01组成的文件每一行对应的01相加 如:10011
编译无措只是执行时候出错,请大家帮我看看 + 01110
= 11121
int main()
{
...............
int *count=new int[100];
ifstream in;
string filename1;
cout<<"please input the filename you want to mine:";
cin>>filename1;
count=generate_set_including_frequent(cel,filename1,in,num_frequent-set1.count);
for(int d;d<20;d++)
cout<<count[d];
return 0;
....................
}
int * generate_set_including_frequent(cell * cell,string& filename1,ifstream in,int length)
{
int *count=new int[200];
in.open(filename1.c_str());
if(in.fail())
{
cout<<"File in.txt could not be opened";
exit(1);
}
else
do
{
string s;
getline(in,s);
for(int i=0;i<length;i++)
cell[i].num_1fre+=::atoi(s.c_str());
}while(!in.eof());
in.close();
for(int j=0;j<length;j++)
count[j]=cell[j].num_1fre;
return count;
}
还有个cell类
class cell
{
public:
int num_1fre;
char _item;
};
这个文件我输入的是bool型的01,而相加需要int型,我把它们取进string类型肯定不妥吧,请高手指点
编译无措只是执行时候出错,请大家帮我看看 + 01110
= 11121
int main()
{
...............
int *count=new int[100];
ifstream in;
string filename1;
cout<<"please input the filename you want to mine:";
cin>>filename1;
count=generate_set_including_frequent(cel,filename1,in,num_frequent-set1.count);
for(int d;d<20;d++)
cout<<count[d];
return 0;
....................
}
int * generate_set_including_frequent(cell * cell,string& filename1,ifstream in,int length)
{
int *count=new int[200];
in.open(filename1.c_str());
if(in.fail())
{
cout<<"File in.txt could not be opened";
exit(1);
}
else
do
{
string s;
getline(in,s);
for(int i=0;i<length;i++)
cell[i].num_1fre+=::atoi(s.c_str());
}while(!in.eof());
in.close();
for(int j=0;j<length;j++)
count[j]=cell[j].num_1fre;
return count;
}
还有个cell类
class cell
{
public:
int num_1fre;
char _item;
};
这个文件我输入的是bool型的01,而相加需要int型,我把它们取进string类型肯定不妥吧,请高手指点
...全文
相关推荐
解决Layui中templet中a的onclick参数传递的问题
今天小编就为大家分享一篇解决Layui中templet中a的onclick参数传递的问题,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
Vue 项目中的 Axios 请求与参数传递问题解析
在 Vue 项目中使用axios发起 HTTP 请求时,参数传递和接口响应是最容易出现问题的两个环节。通过正确的参数传递方式、与后端保持良好的沟通、以及对接口响应进行全面的检查,我们能够快速定位问题并进行修复。同时,合理封装请求逻辑和优化错误处理,不仅能够提升代码的可维护性,还能显著提高用户体验。希望本文的解析能够帮助你更好地理解并解决 Vue 项目中的 Axios 请求问题。
浅谈Java中的参数传递问题
主要介绍了Java中的参数传递问题,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
我遇到的参数传递中 双引号单引号嵌套问题
我遇到的参数传递中 双引号单引号嵌套问题
Android AIDL中Map参数传递的问题详解
主要给大家介绍了关于Android AIDL中Map参数传递问题的相关资料,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友下面来一起看看吧。


