请问下面代码编译成功了,运行没有图像,百思不得其解,希望高人热心指点,在此谢谢!

#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
using pcl::NormalEstimation;
using pcl::search::KdTree;
typedef pcl::PointXYZ PointT;
typedef pcl::PointCloud PointCloud;

void visualize_pcd(PointCloud::Ptr pcd_src1,
PointCloud::Ptr pcd_src2,
PointCloud::Ptr pcd_final)
{
int vp_1, vp_2;
// Create a PCLVisualizer object
pcl::visualization::PCLVisualizer viewer("PCL Viewer");
viewer.createViewPort (0.0, 0, 0.5, 1.0, vp_1);
viewer.createViewPort (0.5, 0, 1.0, 1.0, vp_2);
pcl::visualization::PointCloudColorHandlerCustompcl::PointXYZ src1_h (pcd_src1, 0, 255, 0);
pcl::visualization::PointCloudColorHandlerCustompcl::PointXYZ src2_h (pcd_src2, 255, 0, 0);
pcl::visualization::PointCloudColorHandlerCustompcl::PointXYZ final_h (pcd_final, 0, 255, 0);
viewer.addPointCloud (pcd_src1, src1_h, "vp1_src1", vp_1);
viewer.addPointCloud (pcd_src2, src2_h, "vp1_src2", vp_1);
viewer.addPointCloud (pcd_final, final_h, "vp1_final", vp_2);

viewer.spin();

}

int
main (int argc, char** argv)
{

PointCloud::Ptr cloud_final (new PointCloud);


PointCloud::Ptr cloud_src (new PointCloud);//将长的转成短的//读取点云数据
pcl::io::loadPCDFile ("1.pcd",*cloud_src);
pcl::NormalEstimation<pcl::PointXYZ,pcl::Normal> ne_src;
ne_src.setInputCloud(cloud_src);
pcl::search::KdTree< pcl::PointXYZ>::Ptr tree_src(new pcl::search::KdTree< pcl::PointXYZ>());
ne_src.setSearchMethod(tree_src);
pcl::PointCloud<pcl::Normal>::Ptr cloud_src_normals(new pcl::PointCloud< pcl::Normal>);
ne_src.setRadiusSearch(0.03);
//ne_src.setKSearch(20);二选一
ne_src.compute(*cloud_src_normals);

PointCloud::Ptr cloud_tgt (new PointCloud);
pcl::io::loadPCDFile ("2.pcd",*cloud_tgt);
pcl::NormalEstimation<pcl::PointXYZ,pcl::Normal> ne_tgt;
ne_tgt.setInputCloud(cloud_tgt);
pcl::search::KdTree< pcl::PointXYZ>::Ptr tree_tgt(new pcl::search::KdTree< pcl::PointXYZ>());
ne_tgt.setSearchMethod(tree_tgt);
pcl::PointCloud<pcl::Normal>::Ptr cloud_tgt_normals(new pcl::PointCloud< pcl::Normal>);
//ne_tgt.setKSearch(20);
ne_tgt.setRadiusSearch(0.03);
//compute normal to cloud_normals
ne_tgt.compute(*cloud_tgt_normals);


//fpfh estimation
pcl::FPFHEstimation<pcl::PointXYZ,pcl::Normal,pcl::FPFHSignature33> fpfh_src;
fpfh_src.setInputCloud(cloud_src);
fpfh_src.setInputNormals(cloud_src_normals);
pcl::search::KdTree<PointT>::Ptr tree_src_fpfh (new pcl::search::KdTree<PointT>);
fpfh_src.setSearchMethod(tree_src_fpfh);
pcl::PointCloud<pcl::FPFHSignature33>::Ptr fpfhs_src(new pcl::PointCloud<pcl::FPFHSignature33>());
fpfh_src.setRadiusSearch(0.05);
//fpfh_src.setKSearch(20);
fpfh_src.compute(*fpfhs_src);

pcl::FPFHEstimation<pcl::PointXYZ,pcl::Normal,pcl::FPFHSignature33> fpfh_tgt;
fpfh_tgt.setInputCloud(cloud_tgt);
fpfh_tgt.setInputNormals(cloud_tgt_normals);
pcl::search::KdTree<PointT>::Ptr tree_tgt_fpfh (new pcl::search::KdTree<PointT>);
fpfh_tgt.setSearchMethod(tree_tgt_fpfh);
pcl::PointCloud<pcl::FPFHSignature33>::Ptr fpfhs_tgt(new pcl::PointCloud<pcl::FPFHSignature33>());
fpfh_tgt.setRadiusSearch(0.05);
//fpfh_tgt.setKSearch(20);
fpfh_tgt.compute(*fpfhs_tgt);

//sample consensus initial alignment
pcl::SampleConsensusInitialAlignment<pcl::PointXYZ, pcl::PointXYZ, pcl::FPFHSignature33> scia;
scia.setInputCloud(cloud_src);
scia.setInputTarget(cloud_tgt);
scia.setSourceFeatures(fpfhs_src);
scia.setTargetFeatures(fpfhs_tgt);
//scia.setMinSampleDistance(1);
//scia.setNumberOfSamples(2);
//scia.setCorrespondenceRandomness(20);
PointCloud::Ptr cloud_result_initial (new PointCloud);
scia.align(*cloud_result_initial);
visualize_pcd(cloud_src,cloud_tgt,cloud_result_initial);
std::cout  <<"totals time is:"<<clock()<<std::endl;

return (0);
}

1个回答

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
初学者,希望高人指点
我看得书中有一段这样的代码Data Source=yourserver\\SQLExpressrn我安装的是sql server 2005,而不是sql server 2005 express edition ,所以我想问问这段代码要改成什么,才可以继续?
这个问题,我实在是百思不得其解...希望有高人可以指点
List obj = new List();rnrnobj里面有很多linq的方法.rnrn这里我就不明白了,List这个类型里面根本就没有定义这些linq方法.怎么还可以用呢?rnrn我实在是不明白期中的秘密,希望有高手可以指点.谢谢
希望高人指点入门?
是这样的,我用的是j2ee,我不知道用myeclipse 怎么开发手机的软件?rn我都需要安装什么呢,好像是每个手机都有自己的SDK还是什么?rn我都要下载什么才能进行开发呢。rn想请教各位告之,指点下。rn最好给我下载的路径,都需要什么?我是用myeclipse6.0进行开发的。rn
希望高人指导,谢谢
rn在getServerTime函数中如果我把rn request.onreadystatechange = function()processAJAX(elementContainer);;rn换成rn request.onreadystatechange = processAJAX(elementContainer);rn这样就会报类型错误.这是为什么呀??rn另外rnrnfunction getAJAX(url,elementContainer)rn //document.getElementById(elementContainer).innerHTML = 'Loading...';rn var theHttpRequest = getHttpObject();rn theHttpRequest.onreadystatechange = function() processAJAX(elementContainer);;rn theHttpRequest.open("GET", url);rn theHttpRequest.send(false);rnrn function processAJAX(elementContainer)rn if (theHttpRequest.readyState == 4) rn if (theHttpRequest.status == 200) rn document.getElementById(elementContainer).innerHTML = theHttpRequest.responseText;rn else rn document.getElementById(elementContainer).innerHTML=" 错误信息: " + theHttpRequest.statusText +"<\/p>";rn rn rn rnrnrn这种FUNCTION中嵌套FUNCTION的与分开写的FUNCTION有什么区别呀?谢谢rn
jvm 带来的困惑 --! 希望高人知道 在此谢谢
jvm.h 文件声明的函数rn 在 jvm.cpp 都是这样实现的 rnrn[code=Java]rnJVM_ENTRY(返回值, 方法名(参数))rn。rn。(函数体)rn。rnJVM_ENDrnrn[/code]rnrn那这个JVM_ENTRY 是做了什么,好像就是一个标记 。。整个过程有点像加载类(这里是函数),貌似是 jvm 启动的时候 就加载进去,但是这个过程是什么样的流程,大家都知道 , 在.h的头文件中申明 ,在cpp 文件中都是 用头文件的声明为函数头加以实现,但是这里是用这样一个特殊的结构,难道这个文件不是由c++ 编译 ,一个专用的编译器,那它又是谁呢 --! 困惑rn上网查 都是提下函数体调用一个c++类就走了 望高人 指点下rnrn
请问下面代码的含义,谢谢!
在用VC++的向工程中添加一个新类的时候,在该类的头文件中会有如下代码:rnrn1、#if !defined(AFX_F_H__FA81B7DC_1805_4581_8A5D_7BE457BB72E1__INCLUDED_)rn2、#define AFX_F_H__FA81B7DC_1805_4581_8A5D_7BE457BB72E1__INCLUDED_rnrn3、#if _MSC_VER > 1000rn4、#pragma oncern5、#endif // _MSC_VER > 1000rnrnclass f rnrnpublic:rn f();rn virtual ~f();rnrn;rnrn6、#endif // !definedrn7、(AFX_F_H__FA81B7DC_1805_4581_8A5D_7BE457BB72E1__INCLUDED_)rnrn请问从1到5是什么意思?第6、7中,前面没有相对应底#if,为什么在这里会有一个rn#endif?
麻烦高人指点一下这句代码的运行思路和流程,谢谢~~~
int arr[]=6,7,8,9,10;rnint *ptr=arr;rnprintf("%d,%d,%d,%d,%d\n",*ptr,*(++ptr),*(++ptr),*(++ptr),*(++ptr));rn我在linux下的gcc-2.4.6上跑出来的结果是:10,10,9,8,7不知道为什么,请高手指点一哈。
有高人在吗?希望高人指点一下~!
<%@ page contentType="text/html;charset=gb2312" language= "java" import= "java.io.*,java.sql.*,javax.servlet.*,javax.servlet.http.*" %> rn<%rnrequest.setCharacterEncoding("gb2312");rn%> rn rn 一个简单的聊天室rnrn<%rnString content=(String)getServletContext().getAttribute(new String("chatTopic_1"));rnout.println(content);rngetServletContext().setAttribute("chatTopic_1",content+(String)request.getParameter("content")+ " "); rn%>rnrn rnrnrn怎样改可以不出现中文乱编?rn
最近在做三维点云配准方面研究,下面程序编译成功,没有图像,百思不得其解,希望专家们指点,或者将可供参考源码发本人邮箱3276181394qq.com,xie'x
#include rn#include rn#include rn#include rn#include rn#include rn#include rn#include rn#include rn#include rn#include rn#include rnusing pcl::visualization::PointCloudColorHandlerGenericField;rnusing pcl::visualization::PointCloudColorHandlerCustom;rn//简单类型定义rntypedef pcl::PointXYZ PointT;rntypedef pcl::PointCloud PointCloud;rntypedef pcl::PointNormal PointNormalT;rntypedef pcl::PointCloud PointCloudWithNormals;rn//这是一个辅助教程,因此我们可以负担全局变量rn//创建可视化工具rnpcl::visualization::PCLVisualizer *p;rn//定义左右视点rnint vp_1, vp_2;rn//处理点云的方便的结构定义rnstruct PCDrnrn PointCloud::Ptr cloud;rn std::string f_name;rn PCD() : cloud (new PointCloud) ;rn;rnstruct PCDComparatorrnrn bool operator () (const PCD& p1, const PCD& p2)rn rn return (p1.f_name < p2.f_name);rn rn;rn//以< x, y, z, curvature >形式定义一个新的点rnclass MyPointRepresentation : public pcl::PointRepresentation rnrn using pcl::PointRepresentation::nr_dimensions_;rnpublic:rn MyPointRepresentation ()rn rn //定义尺寸值rn nr_dimensions_ = 4;rn rn //覆盖copyToFloatArray方法来定义我们的特征矢量rn virtual void copyToFloatArray (const PointNormalT &p, float * out) constrn rn // < x, y, z, curvature >rn out[0] = p.x;rn out[1] = p.y;rn out[2] = p.z;rn out[3] = p.curvature;rn rn;rn////////////////////////////////////////////////////////////////////////////////rn/** 在可视化窗口的第一视点显示源点云和目标点云rn*rn*/rnvoid showCloudsLeft(const PointCloud::Ptr cloud_target, const PointCloud::Ptr cloud_source)rnrn p->removePointCloud ("vp1_target");rn p->removePointCloud ("vp1_source");rn PointCloudColorHandlerCustom tgt_h (cloud_target, 0, 255, 0);rn PointCloudColorHandlerCustom src_h (cloud_source, 255, 0, 0);rn p->addPointCloud (cloud_target, tgt_h, "vp1_target", vp_1);rn p->addPointCloud (cloud_source, src_h, "vp1_source", vp_1);rn PCL_INFO ("Press q to begin the registration.\n");rn p-> spin();rnrn////////////////////////////////////////////////////////////////////////////////rn/**在可视化窗口的第二视点显示源点云和目标点云rn*rn*/rnvoid showCloudsRight(const PointCloudWithNormals::Ptr cloud_target, const PointCloudWithNormals::Ptr cloud_source)rnrn p->removePointCloud ("source");rn p->removePointCloud ("target");rn PointCloudColorHandlerGenericField tgt_color_handler (cloud_target, "curvature");rn if (!tgt_color_handler.isCapable ())rn PCL_WARN ("Cannot create curvature color handler!");rn PointCloudColorHandlerGenericField src_color_handler (cloud_source, "curvature");rn if (!src_color_handler.isCapable ())rn PCL_WARN ("Cannot create curvature color handler!");rn p->addPointCloud (cloud_target, tgt_color_handler, "target", vp_2);rn p->addPointCloud (cloud_source, src_color_handler, "source", vp_2);rn p->spinOnce();rnrn////////////////////////////////////////////////////////////////////////////////rn/**加载一组我们想要匹配在一起的PCD文件rn* 参数argc是参数的数量 (pass from main ())rn*参数 argv 实际的命令行参数 (pass from main ())rn*参数models点云数据集的合成矢量rn*/rnvoid loadData (int argc, char **argv, std::vector > &models)rnrn std::string extension (".pcd");rn //假定第一个参数是实际测试模型rn for (int i = 1; i < argc; i++)rn rn std::string fname = std::string (argv[i]);rn // 至少需要5个字符长(因为.plot就有 5个字符)rn if (fname.size () <= extension.size ())rn continue;rn std::transform (fname.begin (), fname.end (), fname.begin (), (int(*)(int))tolower);rn //检查参数是一个pcd文件rn if (fname.compare (fname.size () - extension.size (), extension.size (), extension) == 0)rn rn //加载点云并保存在总体的模型列表中rn PCD m;rn m.f_name = argv[i];rn pcl::io::loadPCDFile (argv[i], *m.cloud);rn //从点云中移除NAN点rn std::vector indices;rn pcl::removeNaNFromPointCloud(*m.cloud,*m.cloud, indices);rn models.push_back (m);rn rn rnrn////////////////////////////////////////////////////////////////////////////////rn/**匹配一对点云数据集并且返还结果rn*参数 cloud_src 是源点云rn*参数 cloud_src 是目标点云rn*参数output输出的配准结果的源点云rn*参数final_transform是在来源和目标之间的转换rn*/rnvoid pairAlign (const PointCloud::Ptr cloud_src, const PointCloud::Ptr cloud_tgt, PointCloud::Ptr output, Eigen::Matrix4f &final_transform, bool downsample = false)rnrn //rn //为了一致性和高速的下采样rn //注意:为了大数据集需要允许这项rn PointCloud::Ptr src (new PointCloud);rn PointCloud::Ptr tgt (new PointCloud);rn pcl::VoxelGrid grid;rn if (downsample)rn rn grid.setLeafSize (0.05, 0.05, 0.05);rn grid.setInputCloud (cloud_src);rn grid.filter (*src);rn grid.setInputCloud (cloud_tgt);rn grid.filter (*tgt);rn rn elsern rn src = cloud_src;rn tgt = cloud_tgt;rn rn //计算曲面法线和曲率rn PointCloudWithNormals::Ptr points_with_normals_src (new PointCloudWithNormals);rn PointCloudWithNormals::Ptr points_with_normals_tgt (new PointCloudWithNormals);rn pcl::NormalEstimation norm_est;rn pcl::search::KdTree::Ptr tree (new pcl::search::KdTree ());rn norm_est.setSearchMethod (tree);rn norm_est.setKSearch (30);rn norm_est.setInputCloud (src);rn norm_est.compute (*points_with_normals_src);rn pcl::copyPointCloud (*src, *points_with_normals_src);rn norm_est.setInputCloud (tgt);rn norm_est.compute (*points_with_normals_tgt);rn pcl::copyPointCloud (*tgt, *points_with_normals_tgt);rn //rn //举例说明我们自定义点的表示(以上定义)rn MyPointRepresentation point_representation;rn //调整'curvature'尺寸权重以便使它和x, y, z平衡rn float alpha[4] = 1.0, 1.0, 1.0, 1.0;rn point_representation.setRescaleValues (alpha);rn //rn // 配准rn pcl::IterativeClosestPointNonLinear reg;rn reg.setTransformationEpsilon (1e-6);rn //将两个对应关系之间的(src<->tgt)最大距离设置为10厘米rn //注意:根据你的数据集大小来调整rn reg.setMaxCorrespondenceDistance (0.1); rn //设置点表示rn reg.setPointRepresentation (boost::make_shared (point_representation));rn reg.setInputCloud (points_with_normals_src);rn reg.setInputTarget (points_with_normals_tgt);rn //rn //在一个循环中运行相同的最优化并且使结果可视化rn Eigen::Matrix4f Ti = Eigen::Matrix4f::Identity (), prev, targetToSource;rn PointCloudWithNormals::Ptr reg_result = points_with_normals_src;rn reg.setMaximumIterations (2);rn for (int i = 0; i < 30; ++i)rn rn PCL_INFO ("Iteration Nr. %d.\n", i);rn //为了可视化的目的保存点云rn points_with_normals_src = reg_result;rn //估计rn reg.setInputCloud (points_with_normals_src);rn reg.align (*reg_result);rn //在每一个迭代之间累积转换rn Ti = reg.getFinalTransformation () * Ti;rn //如果这次转换和之前转换之间的差异小于阈值rn //则通过减小最大对应距离来改善程序rn if (fabs ((reg.getLastIncrementalTransformation () - prev).sum ()) < reg.getTransformationEpsilon ())rn reg.setMaxCorrespondenceDistance (reg.getMaxCorrespondenceDistance () - 0.001);rn prev = reg.getLastIncrementalTransformation ();rn //可视化当前状态rn showCloudsRight(points_with_normals_tgt, points_with_normals_src);rn rn //rn // 得到目标点云到源点云的变换rn targetToSource = Ti.inverse();rn //rn //把目标点云转换回源框架rn pcl::transformPointCloud (*cloud_tgt, *output, targetToSource);rn p->removePointCloud ("source");rn p->removePointCloud ("target");rn PointCloudColorHandlerCustom cloud_tgt_h (output, 0, 255, 0);rn PointCloudColorHandlerCustom cloud_src_h (cloud_src, 255, 0, 0);rn p->addPointCloud (output, cloud_tgt_h, "target", vp_2);rn p->addPointCloud (cloud_src, cloud_src_h, "source", vp_2);rn PCL_INFO ("Press q to continue the registration.\n");rn p->spin ();rn p->removePointCloud ("source"); rn p->removePointCloud ("target");rn //添加源点云到转换目标rn *output += *cloud_src;rn final_transform = targetToSource;rnrn/* [ */rnint main (int argc, char** argv)rnrn pcl::PointCloud::Ptr target1 (new pcl::PointCloud);rn pcl::PointCloud output;rn pcl::io::loadPCDFile (argv[1], *target1);rn pcl::io::loadPCDFile (argv[2], output);rn // 加载数据rn std::vector > data;rn PCD m;rn std::vector indices;rn m.cloud = target1;rn //从点云中移除NAN点rn pcl::removeNaNFromPointCloud(*m.cloud,*m.cloud, indices);rn data.push_back (m);rn m.cloud = output.makeShared();rn pcl::removeNaNFromPointCloud(*m.cloud,*m.cloud, indices);rn data.push_back (m);rnrn //检查用户输入rn if (data.empty ())rn rn return (-1);rn rn PCL_INFO ("Loaded %d datasets.", (int)data.size ());rn PointCloud::Ptr result (new PointCloud), source, target;rn Eigen::Matrix4f GlobalTransform = Eigen::Matrix4f::Identity (), pairTransform;rn for (size_t i = 1; i < data.size (); ++i)rn rn source = data[i-1].cloud;rn target = data[i].cloud;rnrn PointCloud::Ptr temp (new PointCloud);rn PCL_INFO ("Aligning %s (%d) with %s (%d).\n", data[i-1].f_name.c_str (), source->points.size (), data[i].f_name.c_str (), target->points.size ());rn pairAlign (source, target, temp, pairTransform, true);rn //把当前的两两配对转换到全局变换rn pcl::transformPointCloud (*temp, *result, GlobalTransform);rn //update the global transform更新全局变换rn GlobalTransform = pairTransform * GlobalTransform;rn //保存配准对,转换到第一个点云框架中rn std::stringstream ss;rn ss << i << ".pcd";rn pcl::io::savePCDFile (ss.str (), *result, true);rn rnrn
一个setInterval的问题,百思不得其解,望高人指点
有一个关于setInterval的问题,每隔2秒钟弹出提示框,下面是代码:rnrnsetInterval(alerting(),2000);rnrnfunction alerting()rnrn getURL("javascript:alert('abc');");rnrnrn照理说每两秒钟应该会执行一次alerting,但是它只会在flash打开的时候执行一次,以后就不理我了rnrn后来我把第一句改成 setInterval(function () alerting();,2000); 这样就正常了rnrn这是什么原因呢,setInterval的第一个参数应为一个Function名,而alerting()应该也是一个Function名啊,为什么会有这种差别呢rnrn本人比较菜,请高手指点一下,不胜感激!
request.quarystring()出问题了,希望高人指点!
最近我在做一个新闻的动态连接.可是在做到一个页面跳转到另一个页面的时候.rnrequest.quarystring("newsid")老是不赋值.我用的是Dreamweaver MX做的.(ASP.NET +ACCESS)一些代码如下,希望得到高人指点.谢谢!rn第一个页面news.aspxrn<%@ Import Namespace="System.Data" %>rn<%@ Import Namespace="System.Data.OleDb" %>rn
请高人指点~~谢谢!
xp系统, msde 2000 release a,装有一个默认实例,一个命名实例.现另一电脑要调用我本机的命名实例,无论如何都连不上.报server 不存在或访问被拒绝.rn请问各位达人现在如何解决啊??在线等!先谢谢啦!!rn
请高人指点。。谢谢
我想问问,在一个局域网里,是用ADSL上网的,服务器装什么软件可以看到其它CLIENT端的上网IP,而且还可以限制每一部客户端机的上网限制,例如,我分配A机上网是20K,B机是10K,rn请问有没有这种软件,谢谢高手。(最好就是有简单易用的软件吧,)^o^rn
高人指点下:)谢谢
我要做2个功能比较相同的2个windows应用程序,A和Brn他们中 低层很多类都可以通用.我想问下。怎么能在a里调用b中的类呢。..谢谢!!!!
高人指点谢谢
我用以下语句调用存储过程出错rnrnSet rst = New ADODB.RecordsetrnrnSet rst = cmd.Execute("exec JD_Qnddjg_BB1 @Bln_jtlx=0,@strRb='',@Bdate='2006-01-01',@Edate='2006-05-01' ")rnrn请指点
高人指点下,谢谢!
我这弄一个权限的问题,如果登入进来的用户权限是超级管理员index_num=0就可以添加新的管理员,而如果是普通管理员index_num=1进来的时候就不能添加新的管理员rn我写的代码如下:rn<%rnreg = request("reg")rnselect case regrn case "checkqx"rn call checkqx()rnend select rn%>rn rn rn 管理员管理rn rn <%rn sub checkqx()rn anm = session("admin_name")rn set rs=server.CreateObject("adodb.recordset")rn sql = "select * from admin_user where admin_name='"&anm&"'"rn rs.open sql,conn,1,1rn if not rs.eof thenrn if rs("index_num")=1 thenrn response.Write" "rn end ifrn rs.closern set rs=nothingrn end ifrn end subrn %>rn rn 网站配置rn rn rn 数据库备份rn rn rnrnonClick="?reg=checkqx" 这段我怀疑写错了,可我不知道怎么去写rn高人指点下,谢谢
请高人指点,谢谢!
从SQL里读取数据到mshflexgrid里显示不正常,数值型数据:正负零点几前面那个0不见了,SQL里正常显示.(如:-0.7显示为:-.7 而0.7就显示为:.7
线段树,希望能有高人指点。
[code=C/C++]rn#includern#includernusing namespace std;rninline int max(int a,int b)rnrn return a>b?a:b;rnrnstruct Seg_treernrn int left,right;rn int level;rn int exp;rn queueq;rn int calmid()rn rn return (left+right)>>1;rn rn;rnSeg_tree tree[45];rnint arr[11];rnint k;rnvoid build(int left,int right,int idx) //建树rnrn tree[idx].left=left;rn tree[idx].right=right;rn tree[idx].exp=0;rn tree[idx].level=1;rn if(left==right)rn return ;rn int mid=tree[idx].calmid();rn build(left,mid,idx*2);rn build(mid+1,right,idx*2+1);rnrnvoid update(int left,int right,int ei,int idx) //更新节点,先找到对应节点,在把ei放入该节点所定义的队列中。。rnrn if(tree[idx].left==left&&tree[idx].right==right)rn rn tree[idx].q.push(ei);rn return ;rn rn while(!tree[idx].q.empty()) //如果需要更新的节点的祖先的队列里有值,这把该祖先节点的值向下推进。。rn rn int t=tree[idx].q.front();rn tree[idx*2].q.push(t);rn tree[idx*2+1].q.push(t);rn tree[idx].q.pop();rn rn int mid=tree[idx].calmid();rn if(right<=mid)rn update(left,right,ei,idx*2);rn else if(left>mid)rn update(left,right,ei,idx*2+1);rn elsern rn update(left,mid,ei,idx*2);rn update(mid+1,right,ei,idx*2+1);rn rn tree[idx].exp=max(tree[idx*2].exp,tree[idx*2+1].exp);rnrnint down(int idx) //对找到的节点进行处理。。向下推进到叶子节点,更新叶子节点的exp;对每个节点的父节点,返回其子节点的最大exprnrn if(tree[idx].left==tree[idx].right)rn rn while(!tree[idx].q.empty())rn //错误总是在这个地方。。当输入第二组样例时,到这个地方就会出错。。rn int t=tree[idx].q.front();rn tree[idx].q.pop(); rn tree[idx].exp+=t*tree[idx].level;rn if(tree[idx].exp>arr[tree[idx].level]&&tree[idx].levelmid)rn question(left,right,idx*2+1);rn elsern rn question(left,mid,idx*2);rn question(mid+1,right,idx*2+1);rn rn tree[idx].exp =max(tree[idx*2].exp,tree[idx*2+1].exp);rn return tree[idx].exp;rnrnint main()rnrn int T;rn //cin>>T;rn scanf("%d",&T);rn arr[0]=0;rn int j=1;rn while(T--)rn rn //cout<<"Case "<>N>>k>>w;rn scanf("%d%d%d",&N,&k,&w);rn int i;rn for(i=1;i>arr[i];rn scanf("%d",&arr[i]);rn arr[i]+=arr[i-1];rn rn build(1,N,1);rn char ch;rn int a,b,c;rn for(i=0;i>ch;rn if(ch=='W')rn rn //cin>>a>>b>>c;rn scanf("%d%d%d",&a,&b,&c);rn update(a,b,c,1);rn rn if(ch=='Q')rn rn //cin>>a>>b;rn scanf("%d%d",&a,&b);rn cout<
疑问之JTabel,希望高人指点
本人是初学者想知道在label中能不能添加tabel,来操纵数据。rn希望高人能给一个例子:rn在label中添加一个简单的tabel然后把label添加到jFrame容器中(不是把tabel直接添加到jFrame中):rn我从网上找了一个代码,是以label为返回值的,是在label1中加了jTabel后返回添加到另一个label2中,但是在label2中没有显示视图,下面是我从网上搜的代码,把jFrame换成label后的代码,希望各位高人指点rn[code=Java]rnpackage yingyong;rnrnimport java.awt.BorderLayout;rnimport java.awt.Color;rnimport java.awt.event.ActionEvent;rnimport java.awt.event.ActionListener;rnimport java.util.Vector;rnrnimport javax.swing.JButton;rnimport javax.swing.JFrame;rnimport javax.swing.JLabel;rnimport javax.swing.JPanel;rnimport javax.swing.JScrollPane;rnimport javax.swing.JTable;rnimport javax.swing.table.AbstractTableModel;rnimport javax.swing.table.TableColumnModel;rnrnrnpublic class biaoge rn rn rn static String sql;rn public static void set(String str)rn sql=str;rn rn rn private static JLabel label = null;rn private static JTable table = null;rn private static Table_Model model = null;rn private static JScrollPane s_pan = null;rn private static JButton button_1 = null;rn private static JButton button_2 = null;rn private static JButton button_3 = null;rn private static JPanel pane = null;rn public static JLabel xianshi() rn label = new JLabel();rn pane = new JPanel();rn button_1 = new JButton("清除数据");rn button_1.addActionListener(new ActionListener() rn public void actionPerformed(ActionEvent e) rn removeData();rn rn );rn button_2 = new JButton("添加数据");rn button_2.addActionListener(new ActionListener() rn public void actionPerformed(ActionEvent e) rn addData();rn rn );rn button_3 = new JButton("保存数据");rn button_3.addActionListener(new ActionListener() rn public void actionPerformed(ActionEvent e) rn saveData();rn rn );rn pane.add(button_1);rn pane.add(button_2);rn pane.add(button_3);rn model = new Table_Model(20);rn table = new JTable(model);rn table.setBackground(Color.white);rn //String[] age = "16", "17", "18", "19", "20", "21", "22" ;rn // JComboBox com = new JComboBox(age);rn TableColumnModel tcm = table.getColumnModel();rn //tcm.getColumn(3).setCellEditor(new DefaultCellEditor(com));rn tcm.getColumn(0).setPreferredWidth(50);rn tcm.getColumn(1).setPreferredWidth(100);rn tcm.getColumn(2).setPreferredWidth(50);rnrn s_pan = new JScrollPane(table);rnrn label.add(s_pan, BorderLayout.CENTER);rn label.add(pane, BorderLayout.NORTH);rn //frame.getContentPane().add(s_pan, BorderLayout.CENTER);rn //frame.getContentPane().add(pane, BorderLayout.NORTH);rn //frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);rn //frame.setSize(300, 200);rn label.setBounds(0,0,600,500);rn label.setVisible(true);rn return label;rnrn rnrn private static void addData() rn model.addRow("李逵","89.56","89.908","98.34","93.34","21");rn table.updateUI();rn rnrn private static void removeData() rn model.removeRows(0, model.getRowCount());rn table.updateUI();rn rnrn // 保存数据,暂时是将数据从控制台显示出来rn private static void saveData() rn int col = model.getColumnCount();rn int row = model.getRowCount();rn for (int i = 0; i < col; i++) rn System.out.print(model.getColumnName(i) + "\t");rn rn System.out.print("\r\n");rn for (int i = 0; i < row; i++) rn for (int j = 0; j < col; j++) rn System.out.print(model.getValueAt(i, j) + "\t");rn rn System.out.print("\r\n");rn rn System.out.println("------------------------------------");rn rnrnrnrnclass Table_Model extends AbstractTableModel rnrn private static final long serialVersionUID = -7495940408592595397L;rnrn private Vector content = null;rnrn private String[] title_name = "姓名", "智育成绩","思想道德","身心素质","科技人文","时间";rnrn public Table_Model() rn content = new Vector();rn rnrn public Table_Model(int count) rn content = new Vector(count);rn rnrn public void addRow(String name, String zycj, String sxdd,String sxsz,String kjrw,String sj) rn Vector v = new Vector(4);rn v.add(0, name);rn v.add(1, zycj);rn v.add(2, sxdd);rn v.add(3, sxsz);rn v.add(4, kjrw);rn v.add(5, sj);rn content.add(v);rn rnrn public void removeRow(int row) rn content.remove(row);rn rnrn public void removeRows(int row, int count) rn for (int i = 0; i < count; i++) rn if (content.size() > row) rn content.remove(row);rn rn rn rnrn /**rn * 让表格中某些值可修改,但需要setValueAt(Object value, int row, int col)方法配合才能使修改生效rn */rn public boolean isCellEditable(int rowIndex, int columnIndex) rn if (columnIndex == 0) rn return false;rn rn return true;rn rnrn /**rn * 使修改的内容生效rn */rn public void setValueAt(Object value, int row, int col) rn ((Vector) content.get(row)).remove(col);rn ((Vector) content.get(row)).add(col, value);rn this.fireTableCellUpdated(row, col);rn rnrn public String getColumnName(int col) rn return title_name[col];rn rnrn public int getColumnCount() rn return title_name.length;rn rnrn public int getRowCount() rn return content.size();rn rnrn public Object getValueAt(int row, int col) rn return ((Vector) content.get(row)).get(col);rn rnrn /**rn * 返回数据类型rn */rn public Class getColumnClass(int col) rn return getValueAt(0, col).getClass();rn rnrnrn[/code]
下面的代码有漏洞,高人指点下,谢谢!!!
[code=Java][/code]package bmd.jsj.rj.oo1;rnrnimport java.io.*;rnrnpublic class JiSuanFen rnrn /**rn * 功能:有8个裁判进行打分,去掉一个最高分,rn * 去掉一个最低分,最后得分为剩下的6个的平均分rn * 作者:jacobrn * 时间:2011年10月17日 11:51:57rn */rn public static void main(String[] args) rn Judge judge = new Judge();rn rn System.out.println(judge.lastFen());rn rnrnrnclass Judgern float arr[]=null;rn int size=8;rn public Judge()rn arr=new float[size];rn tryrn for(int i=0;iarr[i])rn minFen=arr[i];rn minIndex=i;rn rn rn rn return minIndex;rn rn public int maxFens()rn int maxIndex=0;rn float maxFen=arr[0];rn for(int i=0;i
请问错在哪里??请高人指点。谢谢
namespace d3drn…………rnint EnterMsgLoop(bool (*ptr_display)(float timeDelta));rn…………rnrn///////////////////////////////rnint d3d::EnterMsgLoop( bool (*ptr_display)(float timeDelta) )rnrn//////////////////////////////rnBOOL Display(float timeDelta)rnrn/////////////////////////////rnrn错误是:error C2664: 'EnterMsgLoop' : cannot convert parameter 1 from 'int (float)' to 'bool (__cdecl *)(float)'rn None of the functions with this name in scope match the target type
一个编译连接成功的32位汇编程序,为什么没有成功运行?
我用的是intel汇编第5版,花了好长时间搞定了irvine32包含文件的问题,终于通过编译和连接,但是双击生成的exe文件的时候,根本没反应rn后来的我修改了程序(;部分去掉),应该有弹出对话框的,可是也是没反应。rn我用的是学校的电脑房,xp sp2,administor的账号,用masm32v9rn下面是代码rninclude irvine32.incrncount=5rnrn.datarnarray BYTE count dup(?)rntestarray BYTE 1,2,3,4,5,6,7,8,9,10rnrn.codernmain PROCrn push eaxrn xor eax,eaxrn mov ecx,countrnrnL1:rn rn mov array[eax],alrn inc eaxrn loop L1rnrn movzx eax,[array+1]rn add al,arrayrn call dumpregs ;调用失败??rn ;无法正常调用dumpregs,用msgbox的弹出数来表示eax的值rn ;mov ecx,eaxrn ;mov edx,OFFSET testarrayrn rn;L2:rn rn ;call Msgboxrn ;inc edxrn ;loop L2rnrn pop eaxrn invoke ExitProcess,0rn main ENDPrnrnEND main
编译成功,运行失败!!!
看图:[img=https://img-bbs.csdn.net/upload/201505/30/1432990411_264065.png][/img]rnF5后的错误提示,是什么意思?rnrn再看这个可以通过编译但无法运行的源代码:rn[code=c]#include rn#include rnLRESULT CALLBACK WinSunProc /* 声明一个回调函数 */rn(rn HWND hwnd, /* 窗口的句柄 */rn UINT uMsg, /* 窗口的消息 */rn WPARAM wParam,rn LPARAM lParamrn);rn/*****************************************************rn WinMain:Windows程序的入口函数rn要创建一个完整的窗口需要经过下面4个步骤:设计一个窗口rn类,注册窗口类,创建窗口,显示及更新窗口rn******************************************************/rnint WINAPI WinMainrn(rn HINSTANCE hInstance, // 实例句柄,当前应用程序的实例句柄rn HINSTANCE hPrevInstance, // 默认这个参数为nullrn LPSTR lpCmdLine, // 储存第一个命令行参数rn int nCmdShow)rnrn WNDCLASS wndcls; // 定义一个窗口对象rn wndcls.cbClsExtra=0;rn wndcls.cbWndExtra=0;rnrn wndcls.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); // 指定窗口背景色rn rn wndcls.hCursor = LoadCursor(NULL, IDC_CROSS); // 设置光标样式rn rn wndcls.hIcon = LoadIcon(NULL, IDI_ERROR); // 设置图表样式rn rn wndcls.hInstance = hInstance; // 指定窗口实例句柄rn wndcls.lpfnWndProc = WinSunProc; // 指定窗口函数,即窗口主处理函数rnrn wndcls.lpszClassName = "Visual c++ name"; // 窗口类名称rn wndcls.lpszMenuName = NULL;rnrn wndcls.style = CS_HREDRAW | CS_VREDRAW;rnrn // 注册窗口类rn RegisterClass(&wndcls);rnrn HWND hwnd; // 声明窗口句柄rn hwnd = CreateWindow(rn "Visual C++ Game",rn "Visual C++ 游戏开发",rn WS_OVERLAPPEDWINDOW,rn 200, 200, 600, 400,rn NULL,NULL,hInstance,NULLrn );rn// 在这里真正显示窗口rn ShowWindow(hwnd, SW_SHOWNORMAL);rn UpdateWindow(hwnd); // 更新显示rn/***********************************************************rn初始化工作完成后,WinMain进入所谓的消息循环rn************************************************************/rn MSG msg;rn while(GetMessage(&msg, NULL, 0, 0))rn rn TranslateMessage(&msg); // 转换键盘消息rn DispatchMessage(&msg);rn rn return 0;rnrn/***********************************************************rn窗口函数:窗口函数通常利用switch/case方式判断消息的种类,以rn决定处置方式,由于其被window调用,所以是一种callback函数rn***********************************************************/rnLRESULT CALLBACK WinSunProc(rn HWND hwnd, // 窗口句柄rn UINT uMsg, // 消息rn WPARAM wParam, // 参数1rn WPARAM lParam // 参数2rn )rnrn switch(uMsg)rn rn case WM_PAINT: /* 更新窗口消息 */rn HDC hDC; /* 定义DC设备 */rn PAINTSTRUCT ps;rn hDC = BeginPaint(hwnd, &ps); /* 得到设备HDC */rn TextOut(hDC, 200, 0, "Visual C++ 游戏开发", strlen("Visual C++ 游戏开发"));rn EndPaint(hwnd, &ps);rn break;rn case WM_CLOSE: /* 当单击关闭按钮时,产生关闭消息 */rn if(IDYES==MessageBox(hwnd, "你真要走?", "游戏开发", MB_YESNO))rn rn DestroyWindow(hwnd);rn rn break;rn case WM_DESTROY: /* 销毁窗口消息 */rn PostQuitMessage(0);rn break;rn default:rn // 在这里必须调用DefWindowProc,这是window内部默认的消息处理函数rn return DefWindowProc(hwnd, uMsg, wParam, lParam);rn rn return 0;rn[/code]
编译成功 无法运行
[code=C/C++]#includern#includern rn rn/* A binary tree tNode has data, pointer to left childrn and a pointer to right child */rnstruct tNodernrn int data;rn struct tNode* left;rn struct tNode* right;rn;rn rn/* Structure of a stack node. Linked List implementation is used forrn stack. A stack node contains a pointer to tree node and a pointer torn next stack node */rnstruct sNodernrn struct tNode *t;rn struct sNode *next;rn;rn rn/* Stack related functions */rnvoid push(struct sNode** top_ref, struct tNode *t);rnstruct tNode *pop(struct sNode** top_ref);rnint isEmpty(struct sNode *top);rn rn/* Iterative function for inorder tree traversal */rnvoid postOrder(struct tNode *root)rnrn if(!root)rn return;rn rn /* set current to root of binary tree */rn rn struct sNode *child,*parent = NULL; /* Initialize stack s */rn rn push(&child,root);rn while(!isEmpty(child))rn rn struct tNode *current =pop(&child);rn push(&parent,current);rn rn if(current->left)rn push(&child,current->left);rn if(current->right)rn push(&child,current->right);rn rn rn while(!isEmpty(parent))rn rn struct tNode *current= pop(&parent);rn printf(" %d ",current->data);rn rn rn rn rn/* UTILITY FUNCTIONS */rn/* Function to push an item to sNode*/rnvoid push(struct sNode** top_ref, struct tNode *t)rnrn /* allocate tNode */rn struct sNode* new_tNode =rn (struct sNode*) malloc(sizeof(struct sNode));rn rn if(new_tNode == NULL)rn rn printf("Stack Overflow \n");rn getchar();rn exit(0);rn rn rn /* put in the data */rn new_tNode->t = t;rn rn /* link the old list off the new tNode */rn new_tNode->next = (*top_ref); rn rn /* move the head to point to the new tNode */rn (*top_ref) = new_tNode;rnrn rn/* The function returns true if stack is empty, otherwise false */rnint isEmpty(struct sNode *top)rnrn return (top == NULL)? 1 : 0;rn rn rn/* Function to pop an item from stack*/rnstruct tNode *pop(struct sNode** top_ref)rnrn struct tNode *res;rn struct sNode *top;rn rn /*If sNode is empty then error */rn if(isEmpty(*top_ref))rn rn printf("Stack Underflow \n");rn getchar();rn exit(0);rn rn elsern rn top = *top_ref;rn res = top->t;rn *top_ref = top->next;rn free(top);rn return res;rn rnrn rn/* Helper function that allocates a new tNode with thern given data and NULL left and right pointers. */rnstruct tNode* newtNode(int data)rnrn struct tNode* tNode = (struct tNode*)rn malloc(sizeof(struct tNode));rn tNode->data = data;rn tNode->left = NULL;rn tNode->right = NULL;rn rn return(tNode);rnrn rn/* Driver program to test above functions*/rnint main()rnrn rn /* Constructed binary tree isrn 1rn / \rn 2 3rn / \rn 4 5rn */rn struct tNode *root = newtNode(1);rn root->left = newtNode(2);rn root->right = newtNode(3);rn root->left->left = newtNode(4);rn root->left->right = newtNode(5); rn root->right->left = newtNode(6);rn root->right->right = newtNode(7); rn postOrder(root);rn rn getchar();rn return 0;rn[/code]rnrn编译成功,,,无法运行,,rnrn哪位高人给找一下错误,,
编译成功,运行错误问题
请问下面这个程序为什么用DEV编译运行,输入一个数后就提示运用程序错误,内存不可写?rn#includernmain()rnint i,j,t,m,l,s;rnchar a[100];rnscanf("%d ",t);rngetchar();rnfor(i=0;irnint main()rnrnint T,N,M,x,y,i,j;rnint A[100];rnscanf("%d,&T");rngetchar();rnfor(i=0;iy) printf(">\n");rn else if(xrnint main()rnrn int i,j,n,T;rn long a,b,Ai,Bi;rn float s1,s2;rnfloat c[3];rn scanf("%d",&T);rn scanf("%d",&n);rn for(i=0;is1) s1=c[i];rn rn printf("%.3f",s1);rn getchar();rn return 0;rn rnrnrn各位大侠帮忙看看,感激不尽rnrn
编译成功却不能运行?
#include rn#include rn#include rnrnrn#define null 0;rnvoid mem_cpy(char *s)rnrn s=(char*)malloc(100);rn rnrnvoid main()rnrn char *p;rn p = null;rn char *t ="sdfasdfasdf";rn rn rn mem_cpy(p);rn strcpy(p,t);rn printf("%s",p);rnrnrn把t所指的内容附给p所指的内存区域rn编译通过不能运行rn为什么?rn如何修改?
希望各位指点,谢谢
在存储过程中怎样返回一个错误信息?rn我的存储过程如下:rncreate procedure personsignrn@id varchar(12),rn@password varchar(12),rn@mail varchar(30),rn@oicq varchar(10),rn@pages varchar(100),rn@sign varchar(500),rn@introduce varchar(500)rnasrn if exists(select id from login where id=@id)rn beginrn rn ……怎样返回一个错误信息?rn endrn elsern insert into ……rn endrnreturnrn我不想写两个存储过程,希望各位指点。谢谢
C++代码编译成功,运行出问题了
我这段代码编译通过了,但是运行时候说什么Unhandled exception in main_tempate.exe:0xC0000005:Access Violationrn请高手指教下是什么问题,main函数是老师写的,应该没什么问题,这是个作业,老师把main函数写了,我们把class和成员函数都写了。rn#include rn#include rnrnclass LifeGamernrnpublic:rn LifeGame();rn ~LifeGame();rn void initialize( int w, int h );rn int getWidth() return width;rn int getHeight() return height;rn void setState(int i, int j, bool s);rn void clear();rn void update();rn friend ostream& operator <<( ostream& os, const LifeGame& game );rnrn// bool getState( int i, int j ) const;rnrn bool isExistWorm(int i,int j);rn rn void destroyWorm(int i, int j);rnrn void creatWorm(int i, int j);rnrn void createWormNextGen(int i, int j);rnrnrnrnprivate:rn int width;rn int height;rn bool* current_cells;rn bool decideBirth(int i, int j);rn bool decideSurvival(int i, int j);rn int howManyNeighbor(int i, int j);rn bool *nextgen;rn rn rn;rnrnLifeGame::LifeGame()rnrn width=0, height=0;rnrnrnrnvoid LifeGame::initialize(int w, int h)rnrn int i,j;rn bool* current_cells=new bool[w*h];rn width=w;rn height=h;rn rn rn for(i=0;iwidth * this->height;i++)rn rn current_cells[i] = false; [color=#FF0000]//貌似编译器说这里有问题[/color]rn rn rnrnrnvoid LifeGame::update()rnrn int i,j;rn bool *nextgen = new bool[i*j];rnrn for( i=0;iwidth;i++)rn rn for( j=0;jheight;j++)rn rn nextgen[i*j] = false;rn rn rnrn for( i=0; iwidth; i++ )rn rnrn for( j=0; jheight; j++ )rn rn rn if( isExistWorm( i, j ) == true )rn rn if( decideSurvival( i, j ) == true )rn createWormNextGen( i, j );rn rn elsern rn if( decideBirth( i, j ) == true )rn createWormNextGen( i, j );rn rn rn rnrn for( i=0; iwidth; i++ )rn rn for( int j=0; jheight; j++ )rn current_cells[i*j] = nextgen[i*j];rn rnrnrnbool LifeGame::isExistWorm(int w, int h)rnrn if( w >= 0 && w < this->width && h >= 0 && h < this->height )rn rn return current_cells[w*h];rn rn elsern return false;rnrnrnvoid LifeGame::creatWorm(int i, int j)rn rn if( isExistWorm( i, j ) == false )rn current_cells[i*j] = true;rnrnrnvoid LifeGame::destroyWorm(int i, int j)rnrn if( isExistWorm( i, j ) == true )rn current_cells[i*j] = false;rnrnrnvoid LifeGame::createWormNextGen(int i, int j)rnrn nextgen[i*j]=true;rnrnrnrnbool LifeGame::decideSurvival(int i, int j)rnrn int n = howManyNeighbor( i, j );rn return n == 2 || n == 3; rnrnrnbool LifeGame::decideBirth(int i, int j)rnrn return howManyNeighbor( i, j ) == 3;rnrnrnint LifeGame::howManyNeighbor( int i, int j )rnrn int nCnt = 0;rn nCnt += isExistWorm( i-1, j-1 ) ? 1 : 0;rn nCnt += isExistWorm( i-1, j ) ? 1 : 0;rn nCnt += isExistWorm( i-1, j+1 ) ? 1 : 0;rn nCnt += isExistWorm( i, j-1 ) ? 1 : 0;rn nCnt += isExistWorm( i, j+1 ) ? 1 : 0;rn nCnt += isExistWorm( i+1, j-1 ) ? 1 : 0;rn nCnt += isExistWorm( i+1, j ) ? 1 : 0;rn nCnt += isExistWorm( i+1, j+1 ) ? 1 : 0;rnrn return nCnt;rnrnrnostream& operator <<( ostream& os, const LifeGame& game )rnrn os<< "The current game state is: \n"<> width;rnrn cout << "Input grid height: ";rn cin >> height;rnrn LifeGame life;rn life.initialize( width, height );rn dorn rn int n, i;rnrn cout << "\n[Menu]\n";rn cout << "(0) No change\n";rn cout << "(1) Boat\n";rn cout << "(2) Toad\n";rn cout << "(3) Glider\n";rn cout << "(4) Cross\n";rn cout << "(5) Random\n";rn cout << "Select a command (0-5) : ";rn cin >> n;rnrn switch( n ) rn case 0: break;rn case 1: setBoat( life ); break;rn case 2: setToad( life ); break;rn case 3: setGlider( life ); break;rn case 4: setCross( life ); break;rn case 5: setRandom( life ); break;rn default: break;rn rnrn for( i=0; i < 10; i++ )rn rn cout << "[" << i << "] generation: \n";rn cout << life;rn cout << "\n";rn life.update();rn rnrn cout << "Continue (Y/N)? ";rn cin >> answer;rn rn while( answer == 'Y' || answer == 'y' );rnrnrnvoid setBoat( LifeGame& life )rnrn life.clear();rn int w = life.getWidth();rn int h = life.getHeight();rnrn if( w < 3 || h < 3 )rn rn return;rn rnrn int ci = w / 2;rn int cj = h / 2;rnrn life.setState( ci-1, cj, true );rn life.setState( ci+1, cj, true );rn life.setState( ci, cj-1, true );rn life.setState( ci, cj+1, true );rn life.setState( ci-1, cj-1, true );rnrnrnvoid setToad( LifeGame& life )rnrn life.clear();rn int w = life.getWidth();rn int h = life.getHeight();rnrn if( w < 5 || h < 3 )rn rn return;rn rnrn int ci = w / 2;rn int cj = h / 2;rnrn life.setState( ci, cj, true );rn life.setState( ci-1, cj, true );rn life.setState( ci-2, cj, true );rn life.setState( ci, cj-1, true );rn life.setState( ci-1, cj-1, true );rn life.setState( ci+1, cj-1, true );rnrnrnvoid setGlider( LifeGame& life )rnrn life.clear();rn int w = life.getWidth();rn int h = life.getHeight();rnrn if( w < 3 || h < 3 )rn rn return;rn rnrn int ci = w / 2;rn int cj = h / 2;rnrn life.setState( ci-1, cj, true );rn life.setState( ci, cj-1, true );rn life.setState( ci, cj+1, true );rn life.setState( ci-1, cj-1, true );rn life.setState( ci+1, cj-1, true );rnrnrnvoid setCross( LifeGame& life )rnrn life.clear();rn int w = life.getWidth();rn int h = life.getHeight();rnrn if( w < 3 || h < 3 )rn rn return;rn rnrn int ci = w / 2;rn int cj = h / 2;rnrn life.setState( ci, cj, true );rn life.setState( ci-1, cj, true );rn life.setState( ci+1, cj, true );rn life.setState( ci, cj-1, true );rn life.setState( ci, cj+1, true );rnrnrnvoid setRandom( LifeGame& life )rnrn life.clear();rn int w = life.getWidth();rn int h = life.getHeight();rn int num_cells = w * h;rn int num_live_cells = (int)( (float)num_cells * 0.1f );rnrn for( int c=0; c < num_live_cells; c++ )rn rn int i = rand() % w;rn int j = rand() % h;rnrn life.setState( i, j, true );rn rn
希望高手指点 谢谢!
我在备份的时候用到了CommonDialog控件和filecopy方法备份rnCommonDialog1.Filter = "数据库文件|*.mdb"rnCommonDialog1.ShowSavern FileCopy App.Path & "\数据库\db1.mdb", CommonDialog1.FileNamern最后出现错误:拒绝的权限。rn最后发现是用了commondialog控件后,就不能用filecopy方法了,是吗?rn请大家给予指教。
vector 代码编译成功,但是运行出错。
运行时,windows直接提示程序已停止工作,麻烦帮我看下哪里出问题了。rn[code=c]rn#include rnusing namespace std;rntypedef struct cycledatarnrn unsigned int key;rn int delay;rnCYCLEDATA;rnvector p;rnvoid CreateTestData()rnrn rn CYCLEDATA q[2]=0xffeeddcc,1000,0xaabbccdd,2000;rn p.push_back(q[0]);rn p.push_back(q[1]);rn rnrnvector* Outdata2Byte(vector& p)rnrn unsigned char* buff=NULL,*temp;rn vector::iterator iter;rn vector* outbuff=new vector;rn vector::iterator iter1;rn int len=p.size()*8;rn int i=0,count=0;rn buff=new unsigned char(len);rn temp=buff;rn rn for(iter=p.begin();iter!=p.end();iter++) rn rn *buff++=(iter->key&0xff000000)>>24;rn *buff++=(iter->key&0x00ff0000)>>16;rn *buff++=(iter->key&0x0000ff00)>>8;rn *buff++=iter->key&0xff;rnrn *buff++=(iter->delay&0xff000000)>>24;rn *buff++=(iter->delay&0x00ff0000)>>16;rn *buff++=(iter->delay&0x0000ff00)>>8;rn *buff++=iter->delay&0xff;rn rn rn for(i=0;ipush_back(temp[i]);rn rnrnreturn outbuff; rnrnrnvector* GetTestData(/*vector &p*/)rnrn CreateTestData();rn return Outdata2Byte(p);rnrnrnint main()rnrn vector* p=GetTestData();rn return 0;rnrn[/code]
图像路径错误百思不得其解,求大神指点
我把之前一个项目的生成随机验证码的servlet复制到了一个新的项目里,然后这个图像就死活显示不出来了,我看了一下,应该没什么问题啊,而且我用原来的servlet再生成一个验证码也没有问题。后来我发现,请求根本没有传到现在项目里的servlet,这是为什么呢,求大神指点rnrnUsersManager是我现在的项目,checkcode是我原来的项目,checkcode能显示说明我的代码没问题啊,那是我路径哪里错了吗?rn[img=https://img-bbs.csdn.net/upload/201708/24/1503587341_63084.png][/img]rnrn这是我用servlet写的页面代码rn[img=https://img-bbs.csdn.net/upload/201708/24/1503587473_219900.png][/img]rnrn这是我的文件路径rn[img=https://img-bbs.csdn.net/upload/201708/24/1503587546_275495.png][/img]rn
请高人指点代码~~~~~~~
打开文件”c:\test.txt”,一次读取其中一行文本。令每一行形成一个String,并将读出的String对象转换成大写后置于LinkedList中。最后以相反次序印出LinkedList内的所有文本行。rnrn用java实现,请高人指点代码啊!~~~~~~~~~~~~~rn
请高人指点代码
高手帮忙指点下 rn这段代码用来删除c程序里的注释 rn怎么样才能让它更简洁点 rn程序在命令行输入三个参数 或连个参数都可以运行rn#includern#define MAXSTACK 100rn#define OUT 0rn#define IN 1rntypedef structrn int stacksave[MAXSTACK];rn int top;rnstack;rnstack s;rnvoid check_file(char** file)rnrn char ch,ch1;rn FILE* sourcesfile = NULL, *objfile = NULL;rn if ((sourcesfile = fopen(file[1],"r")) == NULL)rn rn printf("can't open the file %s\n",file[1]);rn exit(1);rn rn if ((objfile = fopen(file[2],"w")) == NULL)rn rn printf("can't open the file %s\n",file[2]);rn exit(1);rn rn while ((ch = fgetc(sourcesfile)) != EOF)rn rn if (ch == 34 )rn rn fputc(ch,objfile);rn while ((ch = fgetc(sourcesfile)) != 34)rn fputc(ch,objfile);rn rn else if (ch == 39)rn rn fputc(ch,objfile);rn while ((ch = fgetc(sourcesfile)) != 39)rn fputc(ch,objfile);rn rn else if (ch == '/')rn rn if ((ch1 = fgetc(sourcesfile)) == '*')rn rn s.stacksave[s.top] = IN;rn s.top++;rn rn elsern rn fputc(ch,objfile);rn fputc(ch1,objfile);rn rn rn else if (ch == '*')rn rn if ((ch1 = fgetc(sourcesfile)) == '/')rn rn if (s.stacksave[s.top-1] == IN)rn s.top--;rn rn elsern rn fputc(ch,objfile);rn fputc(ch1,objfile);rn rn rn else if (s.top == 0)rn fputc(ch,objfile);rn rnrnint main(int argc, char** argv)rnrn if (argc < 2)rn rn printf("To few parmete in the cmd\n");rn exit(0);rn rn if (argc == 2)rn rn argv[2] = "out.c";rn rn s.top = 0;rn check_file(argv);rn return 0;rn
高人指点,以下代码
通过以下方法获取打印[b]多份[/b]文档的总页数,可是得到是却一份的页数rn;代码如下所示:我怎样获取打印的份数呢,用其他什么方法也行,最好提供完整的代码rnstring searchQuery = "SELECT * FROM Win32_PrintJob";rnrn ManagementObjectSearcher searchPrintJobs = rn new ManagementObjectSearcher(searchQuery);rn ManagementObjectCollection prntJobCollection = searchPrintJobs.Get();rn int i=1;rn foreach(ManagementObject prntJob in prntJobCollection)rn rn string documentName = prntJob.Properties["Document"].Value.ToString();rn string owner= prntJob.Properties["Owner"].Value.ToString();rn string pages= prntJob.Properties["TotalPages"].Value.ToString();rn string pagesPrinted= prntJob.Properties["PagesPrinted"].Value.ToString();rn string timer= prntJob.Properties["TimeSubmitted"].Value.ToString();rn
请问下面哪个没有返回值,谢谢啊
rnstring transfer::find(string temp)rn rn scaniter=finditer;rn string::size_type i;rn while(scaniter!=allline.end())rn rn i=(*scaniter).find(temp);rn if(i!=string::npos)rn rn finditer=scaniter+1;rn return *scaniter;rn rn elsern rn scaniter++;rn if(scaniter==allline.end())rn finditer=scaniter;//这要是没,我不需要的rn rn rn if(scaniter==allline.end()) return "1";rn rn
编译rtlinux时出现的问题,希望高人指点
redhat 9.0 Kernel 2.4.20-8 rn下载软件: linux-2.4.20.tar.bz2 rn rtlinux-3.2-pre3.tar.bz2 rn当我patch 完,reboot进入rtlinux 准备用rtlinux start 来加载mobuff.o,rtl.o,rtl_time.o等模块时出现问题: rnUsing /usr/rtlinux-3.2-pre2/modules/mbuff.o rnWarning: loading /usr/rtlinux-3.2-pre2/modules/mbuff.o will taint the kernel: no license See http://www.tux.org/lkml/#export-tainted for information about tainted modules rnModule mbuff loaded, with warnings rnrn之后我就单个insomd,结果: rnrn[root@beyond root]# insmod rtl_time rnUsing /usr/rtlinux-3.2-pre2/modules/rtl_time.o rn/usr/rtlinux-3.2-pre2/modules/rtl_time.o: unresolved symbol rtl_printf rn/usr/rtlinux-3.2-pre2/modules/rtl_time.o: unresolved symbol rtl_request_local_irq rn/usr/rtlinux-3.2-pre2/modules/rtl_time.o: unresolved symbol rtl_rt_system_is_idle rn/usr/rtlinux-3.2-pre2/modules/rtl_time.o: unresolved symbol rtl_request_global_irq rn/usr/rtlinux-3.2-pre2/modules/rtl_time.o: unresolved symbol rtl_hard_enable_irq rn/usr/rtlinux-3.2-pre2/modules/rtl_time.o: unresolved symbol rtl_free_local_irq rn/usr/rtlinux-3.2-pre2/modules/rtl_time.o: unresolved symbol rtl_free_global_irq rn/usr/rtlinux-3.2-pre2/modules/rtl_time.o: unresolved symbol rtl_global_pend_irq rn/usr/rtlinux-3.2-pre2/modules/rtl_time.o: unresolved symbol rtl_global_ispending_irq rn/usr/rtlinux-3.2-pre2/modules/rtl_time.o: unresolved symbol rtl_local_pend_vec rnrn同时加载其他模块时也出现了同样的问题rn大家有遇到过类似的问题吗?请指点一下 rnrn
初学,如何导入别人的代码,并编译成功呀?没有分,请指点,初学。。。谢谢
要想把网上的源代码放到自己新建的一个项目中,应该怎么做?我打开delphi就有一个form1,那么如何正确地导入别人的源代码,如果别人的源代码中也有form,如何生成呢?rnrn初学delphi请多多指教!谢谢。
一个让小弟百思不得其解的问题。希望各大侠指点指点
问题rnrn企业喜欢用容易被记住的电话号码。让电话号码容易被记住的一个办法是将它写成一个容易记住的单词或者短语。例如,你需要给滑铁卢大学打电话时,可以拨打TUT-GLOP。有时,只将电话号码中部分数字拼写成单词。当你晚上回到酒店,可以通过拨打310-GINO来向Gino's订一份pizza。让电话号码容易被记住的另一个办法是以一种好记的方式对号码的数字进行分组。通过拨打必胜客的“三个十”号码3-10-10-10,你可以从他们那里订pizza。 rnrn电话号码的标准格式是七位十进制数,并在第三、第四位数字之间有一个连接符。电话拨号盘提供了从字母到数字的映射,映射关系如下: rnA, B, 和C 映射到 2 rnD, E, 和F 映射到 3 rnG, H, 和I 映射到 4 rnJ, K, 和L 映射到 5 rnM, N, 和O 映射到 6 rnP, R, 和S 映射到 7 rnT, U, 和V 映射到 8 rnW, X, 和Y 映射到 9 rnrnQ和Z没有映射到任何数字,连字符不需要拨号,可以任意添加和删除。 TUT-GLOP的标准格式是888-4567,310-GINO的标准格式是310-4466,3-10-10-10的标准格式是310-1010。 rnrn如果两个号码有相同的标准格式,那么他们就是等同的(相同的拨号) rnrn你的公司正在为本地的公司编写一个电话号码薄。作为质量控制的一部分,你想要检查是否有两个和多个公司拥有相同的电话号码。 rnrnInputrnrn输入的格式是,第一行是一个正整数,指定电话号码薄中号码的数量(最多100000)。余下的每行是一个电话号码。每个电话号码由数字,大写字母(除了Q和Z)以及连接符组成。每个电话号码中只会刚好有7个数字或者字母。rnOutputrnrn对于每个出现重复的号码产生一行输出,输出是号码的标准格式紧跟一个空格然后是它的重复次数。如果存在多个重复的号码,则按照号码的字典升序输出。如果输入数据中没有重复的号码,输出一行: rnNo duplicates. rnrnSample Inputrnrn12rn4873279rnITS-EASYrn888-4567rn3-10-10-10rn888-GLOPrnTUT-GLOPrn967-11-11rn310-GINOrnF101010rn888-1200rn-4-8-7-3-2-7-9-rn487-3279rnrnSample Outputrnrn310-1010 2rn487-3279 4rn888-4567 3rnrnrn我的程序:rnrn#include rn#include rn#include rnrnint *init_(int n)//初始化rnrn int *c;rn if(!(c=(int *)malloc(n))) exit(0);rn for(int i=0;i'a'&&c<'z') return a[c-'a'];rn if(c>'A'&&c<'Z') return a[c-'A'];rnrnrnvoid input_(int *a,int n)//保存输入,将一个号码保存为一个7位数rnrn int i=0,m,t;rn char c;rn while(i'a'&&c<'z')||(c>'A'&&c<'Z'))rn m=search_(c); //字母转化为对应的数字rn else m=c-'0';rn if(m==-1) exit(0);//输入不合格rn a[i]=a[i]*10+m;rn t++;rn rn i++;rn rnrnrnvoid stict(int *a,int *b,int n)//号码个数统计,存于b数组中rnrn int i,j;rn for (i=0;i0)rn rn for(j=i+1;j100000) exit(0);rn a=init_(n);rn input_(a,n);rn int *b=init_(n);rn stict(a,b,n);rn for(i=0;i0)rn printf("%d-%d %d\n",(*(a+i))/10000,(*(a+i))%10000,*(b+i));rngetchar();getchar();rn return 0;rnrnrn我用devcpp调试,在n比较小的时候,输出是对的,但在输出完毕后不是正常终止,或者n比较大大时,根本就没输出……小弟我百思不得其解,恳请各位大侠指点啊!谢谢
百思不得其解,请高人指教!
百思不得其解,请高人指教!rnrn我使用c#和Sql Server来制作asp.net页面,其中有一项是:rn 将文本框中的内容提交到数据库中,如果是纯文本,操作正确,但是如果是下面的内容:rn 比如:rn rn 如果是上面的文本,就会出现错误,不知道是为什么,好象是web.config中出错了,请指教!
VC++ 抓取网页 编译成功 运行不可以 求高人解答
#include rn#include rn rnint main(int argc, char* argv[]) rn rnrnrn CInternetSession session("HttpClient"); rn char * url = "www.baidu.com"; rn CHttpFile* pfile = NULL ;rn pfile =(CHttpFile *)session.OpenURL(url); rn rn DWORD dwStatusCode; rn pfile -> QueryInfoStatusCode(dwStatusCode); rn if(dwStatusCode == HTTP_STATUS_OK) rn rn CString content; rn CString data; rn while (pfile -> ReadString(data)) rn rn content += data + "\r\n"; rn rn content.TrimRight(); rn printf(" %s\n " ,(LPCTSTR)content); rn rn pfile -> Close(); rn rn session.Close(); rn rn return 0 ; rn
相关热词 c# 去空格去转义符 c#用户登录窗体代码 c# 流 c# linux 可视化 c# mvc 返回图片 c# 像素空间 c# 日期 最后一天 c#字典序排序 c# 截屏取色 c#中的哪些属于托管机制