这是关于SQL Server 2012 Management Studio.我正在训练我的SQL技能,手动创建查询.
现在我想在Users表中插入几条记录.如您所见,存在一个列GroupID,它是另一个表的外键Groups.

但是当我写一个查询时:
insert into Users (Username, Pass, FullName, GroupID)
values ('Tyana', '17890', 'Tyana Stoyanov', 4)
Run Code Online (Sandbox Code Playgroud)
我收到一个错误:
列名称GroupID无效

这是为什么?
我有以下练习:数字n0到n7是二进制系统中表示的字节.任务是一点点掉到底部,或者如果它遇到另一个位,它会保持在它之上.这是一个视觉示例:

我意识到如果我对从n0到n7的所有数字应用Bitwise OR,它总是n7的正确结果:
n7 = n0 | n1 | n2 | n3 | n4 | n5 | n6 | n7;
Console.WriteLine(n7); // n7 = 236
Run Code Online (Sandbox Code Playgroud)
不幸的是,我想不出其余字节n6,n5,n4,n3,n2,n1,n0的正确方法.你有什么想法?
我即将在我的64位计算机上安装SQL Server 2012 Developer用于开发目的,但我不确定是否应该安装32位或64位版本.
我的困惑来自于我的Visual Studio 2012是32位而我的笔记本电脑不是很快(英特尔Core2Duo P8400 @ 2.26Ghz,带5GB RAM).
一般来说,在64位机器上安装64位或32位应用程序是正确的选择吗?
我的真正目的是获得唯一出现奇数次数的数组元素.所以我发现它可以通过对阵列的所有元素进行异或来完成.像这样:
int[] arr = { 3, 4, 7, 7, 0, 4, 0, 7, 3 };
Console.WriteLine(arr[0] ^ arr[1] ^ arr[2] ^ arr[3] ^ arr[4] ^ arr[5] ^ arr[6] ^ arr[7] ^ arr[8]);
Run Code Online (Sandbox Code Playgroud)
然而问题是没有给出数组,而是从控制台读取数组,因此我不知道如何在输入后对元素进行异或.我到目前为止可以解决的代码是:
编辑:由于你的帮助,我设法正确完成了代码.
static void Main()
{
int N = int.Parse(Console.ReadLine());
long[] rectArray = new long[N];
for (int i = 0; i < N; i++)
{
rectArray[i] = long.Parse(Console.ReadLine());
}
long initial = rectArray[0];
for (int i = 1; i < rectArray.Length; ++i)
{
initial ^= rectArray[i];
}
Console.WriteLine(initial); …Run Code Online (Sandbox Code Playgroud) 简而言之,过去6个月我一直在参加C#课程.我们涵盖了语言的所有基础知识 - 变量,数组,方法,循环,文本处理,使用字符串等进行大量练习......但总的来说,这些材料正在改进我的算法思维(我没有任何编程背景)事情进展顺利.
然而,从二月中旬开始,我们开始了OOP,艰难时期到了.尽管我在理论上对它们有所了解,但实施OOP原则对我来说是一场噩梦.
我该怎么做才能帮助自己:
请你给我一些建议,因为我不想放弃!?
我遇到过这种情况,其中List没有指定类型<>:
List someVar = new List();
Run Code Online (Sandbox Code Playgroud)
但是,当我在Visual Studio中尝试此操作时,我收到错误.VS不让我这样声明的原因是什么List?
让我告诉你我在哪里看到它:
public override IEnumerable SomeMethod()
{
List someVar= new List();
// more code
return someVar;
}
Run Code Online (Sandbox Code Playgroud)
PS它变成了该项目的所有者联系后WordPress的条纹出来的标签<>后List和IEnumerable,因此它实际上应该是List<SomeClass>和IEnumerable<SomeClass>
public override IEnumerable<SomeClass> SomeMethod()
{
List<SomeClass> someVar= new List<SomeClass>();
// more code
return someVar;
}
Run Code Online (Sandbox Code Playgroud) 我的每个Nightwatch.js测试都需要身份验证才能运行,目前我无法通过cookie进行身份验证(当然,如果测试填写了它登录的用户名和密码,但这需要时间)
我有一个工作的PHPSESSID(在Fiddler测试)cookie并试图通过nightwatch setCookie函数设置它像这样:
browser
.setCookie({
name : "PHPSESSID",
value : "gfnpqlflvlrkd2asj18ja2ewrt",
path : "/admin", //(Optional)
domain : "example.com", //(Optional)
secure : true, //(Optional)
httpOnly : false // (Optional)
})
.url("www.example.com/admin")
Run Code Online (Sandbox Code Playgroud)
然而,www.example.com/admin重新定向回到www.example.com/login意味着身份验证没有通过.
有什么解决方案吗?
任务是找到一个至少有500个除数的三角形数.
例如28有6个除数: 1,2,4,7,14,28
我的代码适用于多达200个除数,但对于500,它会永远运行...
有没有办法优化代码.比如我想过动态优化和memoization,但找不到办法呢?
int sum = 0;
int counter = 0;
int count = 1;
bool isTrue = true;
while (isTrue)
{
counter = 0;
sum += count;
for (int j = 1; j <= sum; j++)
{
if (sum % j == 0)
{
counter++;
if (counter == 500)
{
isTrue = false;
Console.WriteLine("Triangle number: {0}", sum);
break;
}
}
}
count++;
}
Console.WriteLine("Number of divisors: {0}", counter);
Run Code Online (Sandbox Code Playgroud) c# ×5
sql ×2
32bit-64bit ×1
arrays ×1
bitwise-or ×1
console ×1
divider ×1
insert ×1
list ×1
oop ×1
optimization ×1
sql-server ×1
types ×1
xor ×1