如果我有一个int说306.什么是分开数字3 0 6的最佳方法,所以我可以单独使用它们?我在想将int转换为字符串然后解析它?
int num;
stringstream new_num;
new_num << num;
Run Code Online (Sandbox Code Playgroud)
我不知道如何解析字符串.建议?
在c#中是否有像c ++ map这样的结构?我有一组像这样的数字:
1.234 1
5.789 0
3.445 1
...
我需要根据第一列中的最小数字对数据进行排序,但我需要第一列数字与第二列中每个受尊重的数字保持一致.所以在排序后它看起来像这样:
1.234 1
3.445 1
5.789 0
...
有任何想法吗?
我有一个这样的类,我使用作为数组中的点:
class Point
{
public int x;
public int y;
public Point(int x, int y)
{
this.x = x;
this.y = y;
}
}
Run Code Online (Sandbox Code Playgroud)
然后我试图获得最接近结束的值:
public void Position()
{
for (int x = 0; x < arr.Length; x++)
{
for (int y = 0; y < arr[x].Length; y++)
{
if (arr[x][y] == 3)
Pos.x = x;
Pos.y = y;
if (arr[x][y] == 1)
Pos.x = x;
Pos.y = y;
if (arr[x][y] == 2)
Pos.x = x;
Pos.y = y;
} …Run Code Online (Sandbox Code Playgroud) 这不起作用:
string fileContent = Resource.text;
StreamReader read = File.OpenText(fileContent);
string line;
char[] splitChar = "|".ToCharArray();
while ((line = read.ReadLine()) != null)
{
string[] split = line.Split(splitChar);
string name = split[0];
string lastname = split[1];
}
read.Dispose();
Run Code Online (Sandbox Code Playgroud)
如何打开资源文件以获取其内容?
如果我有这样的功能:
void myfunction(node* root)
{
for(int i = 0; i<root->children.size();i++)
{
myfunction(root->children[i]);
}
}
Run Code Online (Sandbox Code Playgroud)
那是n ^ 2的大O还是n的大O?如果你有一个for循环并且在for循环中有一个函数调用它自己,那么Big O迭代次数是函数的吗?
在Actionscript中,您可以拥有如下全局变量:
var number : Number = 15;
Run Code Online (Sandbox Code Playgroud)
然后在方法/函数中使用它.你如何在Objective-c中做到这一点,是否可能?
如果我有这样的地图:
std::map<char, std::vector<char> > m;
m['A'].push_back('a');
m['A'].push_back('b');
m['A'].push_back('c');
m['B'].push_back('h');
m['B'].push_back('f');
Run Code Online (Sandbox Code Playgroud)
我如何找到并删除'b'?这可能吗?
您将如何将所有12个月及其正确的天数存储在阵列中?制作一个12乘31的阵列在几个月中有两个很多,比如2月只有28天.行将是月份,列将是天数.建议?
我试图搜索文本文件并找到有效的电子邮件地址.我做这样的事情:
#!/usr/bin/perl -w
my $infile = 'emails.txt';
open IN, "< $infile" or die "Can't open $infile : $!";
while( <IN> )
{
if ($infile =~ /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,6}$/)
{
print "Valid \n";
}
}
close IN;
Run Code Online (Sandbox Code Playgroud)
但它没有做任何事情,任何帮助?