吸血鬼号码在这里定义https://en.wikipedia.org/wiki/Vampire_number.数字V是吸血鬼号码,如果:
我提出了一个解决方案,
strV = sort(toString(V))
for factor <- pow(10, N/2) to sqrt(V)
if factor divides V
X <- factor
Y <- V/factor
if X and Y have trailing zeros
continue
checkStr = sort(toString(X) + toString(Y))
if checkStr equals strV return true
Run Code Online (Sandbox Code Playgroud)
另一种可能的解决方案是置换由V表示的字符串并将其分成两半并检查它是否是吸血鬼号码.哪一个是最好的方法呢?
我试图通过REST API将文件发送到服务器.该文件可能是任何类型的,但它的大小和类型可以限制为可以作为电子邮件附件发送的内容.
我认为我的方法是将文件作为二进制流发送,然后在它到达服务器时将其保存回文件中.是否有内置的方法在.Net中执行此操作,还是需要手动将文件内容转换为数据流并发送?
为清楚起见,我可以控制客户端和服务器代码,因此我不限于任何特定方法.
我有以下代码的问题:
using System;
class Yellow
{
static void Main()
{
Console.WriteLine("Check_1");
Console.ReadKey();
Console.WriteLine("Check_2");
char beep = '\a';
int i = 3;
while (!Console.KeyAvailable)
{
Console.WriteLine(beep);
System.Threading.Thread.Sleep(200);
Console.WriteLine("Check_" + i);
i++;
}
}
}
Run Code Online (Sandbox Code Playgroud)
在等待输入字符开始之后,该程序Check_<i>在每个循环之间输出一个蜂鸣声和一个等待200毫秒的消息.如果在该循环期间按下某个键,程序将终止.
但是,当我等待循环运行多次(大约36次)时,当我按下一个键时循环不会中断.当我尝试使用X按钮手动关闭控制台时,程序没有响应.
如果循环运行了几十次,为什么会这么重要?
当我尝试编译它时,下面的代码给出了一个错误"无效的表达式术语'else'".我无法弄清楚如何解决它:
public double CalcTicketCost(int section, double quantity)
{
double amount = 0;
if (int.Parse(lstSectionNumber.SelectedItem.Value) < 150)
{
amount = premiumTicket * quantity;
return amount;
}
{
else (int.Parse(lstSectionNumber.SelectedItem.Value) > 150) // This line is where the problem seems to be
amount = basicTicket * quantity;
}
return amount;
}
Run Code Online (Sandbox Code Playgroud)