我正在使用PAR :: Packer,这个问题出现在我的脑海里.PAR :: Packer如何在Perl中工作?它是否真的将Perl脚本编译为.exe,就像g ++将C++源代码编译为.exe一样,还是像Python中的py2exe一样将解释器和脚本打包成.exe?
我在Project Euler上解决问题25.我在C#中为它编写了一个代码.但是在这种情况下,我需要使用"BigInt",因为Int64不足以容纳数字.但是,当我放置时,它会在编译期间给出错误消息(标题中的消息).为什么是这样?我使用的是Mono 2.10.9.using System.Numerics;
我的代码:
using System;
using System.Numerics;
public class Problem_25{
static BigInt fib(int n){
double Phi = (1+Math.Sqrt(5))/2;
double phi = (1-Math.Sqrt(5))/2;
BigInt an = Convert.BigInt((Math.Pow(Phi, n)-(Math.Pow(phi, n)))/Math.Sqrt(5));
return an;
}
static void Main(){
int i = 100;
int answer = 0;
string current_fn = "1";
while(true){
current_fn = Convert.ToString(fib(i));
if(current_fn.Length == 1000){
answer = i;
break;
}
else{
i++;
}
}
Console.WriteLine("Answer: {0}", answer);
}
}
Run Code Online (Sandbox Code Playgroud) 只是想知道,有可能在C#中计算负数的平方根吗?例如sqrt(-1)= i.
我写了这段代码:
using System;
public static class sqrts
{
public static void Main()
{
string x;
double sqrtofx;
Console.Write("Enter a number: ");
x = Console.ReadLine();
sqrtofx = Math.Sqrt(Convert.ToInt32(x));
Console.WriteLine("\nSqrt({0}): {1}", x, sqrtofx);
Console.ReadKey();
}
}
Run Code Online (Sandbox Code Playgroud)
如果我输入25,它会给出5.然而,如果我输入-5,它会给出NaN而不是5i.
我正在制作一个将英语句子转换为Pig Latin的程序(因为我很无聊).代码看起来非常好,但是当我输入一个句子时它会抛出错误.我不知道为什么会给出错误.
代码:
use strict;
use warnings;
sub to_pig_latin
{
my $sentence = shift;
my @words = split(" ", $sentence);
my $translated = " ";
my $cw;
for(my $i = 0; $i < scalar(@words); $i++)
{
my $word = $words[$i];
if($word eq "." or $word eq "!" or $word eq "?")
{
}
else
{
$cw = substr(1, length($word)-1, $word);
$translated = $translated.$cw.substr(0,1,$word)."ay"." ";
}
}
return $translated;
}
print "Welcome to English -> Pig Latin Converter.\n";
print "Enter an …Run Code Online (Sandbox Code Playgroud) 我正在创建一个程序,它接受用户的用户名,年龄和ID,然后将它们打印到屏幕上.用户名不能包含任何符号或空格(_除外).所以,我创建了一个函数,true如果名称中包含符号,则返回该函数,false如果不符号则返回.但是我在编译期间遇到错误:No overload for method 'Exists' takes '1' arguments.完整的错误:
challenge_2.cs(23,37): error CS1501: No overload for method `Exists' takes `1' arguments
/usr/lib/mono/2.0/mscorlib.dll (Location of the symbol related to previous error)
Compilation failed: 1 error(s), 0 warnings
Run Code Online (Sandbox Code Playgroud)
这是代码:
using System;
using System.Collections.Generic;
public class Challenge_2
{
static string myName;
static string myAge;
static string myUserID;
public static char[] break_sentence(string str)
{
char[] characters = str.ToCharArray();
return characters;
}
public static bool check_for_symbols(string s)
{
string[] _symbols_ = …Run Code Online (Sandbox Code Playgroud)