小编Pra*_*hur的帖子

C++中的浮点异常

我在我的代码中遇到浮点异常但无法对其进行排序.我不知道问题是什么.不太擅长C++程序,只是通过给出的公式.请帮我:

程序:

#include<iostream.h>
#include<conio.h>
#include <stdlib.h>

void main()
{
    clrscr();
    int a,b,c,d,ctr,j,Q=1,K=1 ;
    float q0=0.7, p = 0.5 ;
    int phe[3][3];
    double dist[3][3] , mem[3][3],exp[3][3],eplt[3][3], rnd;
    cout<<"enter the iterations, cities , ants ";
    cin>>a>>b>>c;
    for (int i=0;i<3;i++)
    {
        for (j=0;j<3;j++)
        {
            dist[i][j]=(double)rand()/(double)RAND_MAX;
            if (i==j)
            dist[i][j]=0;
        }
    }
    for (i=0;i<3;i++)
    {
        for (j=0;j<3;j++)
        {
            cout<< dist[i][j]<<"\t";
        }
        cout<<"\n";
    }

    cout<<"pheromone matrix "<<endl;
    for (i=0;i<3;i++)
    {
        for (j=0;j<3;j++)
        {
            if (i==j)
                phe[i][j]=0;
            else
                phe[i][j]=1;
        }
    }

    for ( i=0;i<3;i++)
    {
        for ( …
Run Code Online (Sandbox Code Playgroud)

c++ floating-point exception

3
推荐指数
1
解决办法
1178
查看次数

用于查找和替换XML中的标记值的Perl代码

以下是我将使用的XML:

<a>

<id>ABC</id>

<class />

<gender />

</a>

我想编写一个Perl代码,用于搜索标签'id'并将值"ABC"替换为"DEF".

但是,上述XML的嵌套可能会发生变化.因此,我想制作一个通用代码,独立于其确切位置搜索标签'id'.

直到现在我能够获得逻辑,我可以替换ABC中的值,但这使我的代码静态标记'id'的位置.

#!usr/bin/perl
use warnings;
use XML::Simple;
use Spreadsheet::ParseExcel;
use Data::Dumper;
my $FileName = 'sample.xls';
my $xml_file = 'hello.xml';
$par=$ARGV[0];
my $xml = XMLin($xml_file,
    KeepRoot=>1,
    ForceArray=>1,);
$xml->{a}->[0]->{id}='DEF';
XMLout(
    $xml,
    KeepRoot =>1 ,
    NoAttr =>1,
    OutputFile => $xml_file,
        );
    }
Run Code Online (Sandbox Code Playgroud)

xml perl xml-simple

3
推荐指数
1
解决办法
4470
查看次数

Perl错误"无法在Parser.pl第6行的未定义值上调用方法"get_tag"

我写了一个简单的perl脚本但是我收到了这个运行时错误:

无法在Parser.pl第6行的未定义值上调用方法"get_tag"

以下是我的代码:

#!usr/bin/perl
use HTML::TokeParser
my $p=HTML::TokeParser->new('bad.html');
while (my $token=$p->get_tag('a')){
my $url=$token->[1]{href};
print "$url\n";
}
Run Code Online (Sandbox Code Playgroud)

我在这个perl程序的同一目录下放置了一个文件bad.html.以下是bad.html的代码

<html><body>
<a href="https://www.Google.com">Google</a>
<a href="https://www.yahoo.com">Yahoo</a>
</body></html>
Run Code Online (Sandbox Code Playgroud)

请帮我解决运行perl代码时出错的问题.

perl www-mechanize html-parsing html-parser

1
推荐指数
1
解决办法
786
查看次数

perl-cgi程序中的500内部服务器错误

我收到错误"内部服务器错误.服务器遇到内部错误或配置错误,无法完成您的请求."

我在html中提交表单并获取其值.

HTML代码(index.cgi)

#!c:/perl/bin/perl.exe
print "Content-type: text/html; charset=iso-8859-1\n\n";
print "<html>";
print "<body>";
print "<form name = 'login' method = 'get' action = '/cgi-bin/login.pl'> <input type = 'text' name = 'uid'><br /><input type = 'text' name = 'pass'><br /><input type = 'submit'>";
print "</body>";
print "</html>";
Run Code Online (Sandbox Code Playgroud)

用于获取数据的Perl代码(login.pl)

#!c:/perl/bin/perl.exe
use CGI::Carp qw(fatalsToBrowser);
my(%frmfields);
getdata(\%frmfields);
sub getdata {
    my ($buffer) = "";
    if (($ENV{'REQUEST_METHOD'} eq 'GET')) {
        my (%hashref) = shift;
        $buffer = $ENV{'QUERY_STRING'};
        foreach  (split(/&/,$buffer)) {
            my ($key, $value) = split(/=/, $_); …
Run Code Online (Sandbox Code Playgroud)

forms perl cgi cgi-bin internal-server-error

0
推荐指数
1
解决办法
2060
查看次数