我想要做的是将表与另一个临时表进行比较,如果记录尚未存在,请将其插入表中.我的问题是IF NOT EXIST似乎不正确.如果我把代码分开,我遇到的问题是:
返回29结果:
SELECT *
from NO_STOCK INNER JOIN #no_stock
ON NO_STOCK.PRODUCT_CODE = #no_stock.PRODUCT_CODE
WHERE NO_STOCK.PRODUCT_CODE = #no_stock.PRODUCT_CODE.
Run Code Online (Sandbox Code Playgroud)
这没有返回任何结果(我希望这会返回34):
SELECT PRODUCT_CODE
FROM #no_stock
WHERE NOT EXISTS
(SELECT * from NO_STOCK INNER JOIN #no_stock
ON NO_STOCK.PRODUCT_CODE = #no_stock.PRODUCT_CODE
WHERE NO_STOCK.PRODUCT_CODE = #no_stock.PRODUCT_CODE)
Run Code Online (Sandbox Code Playgroud)
这返回63:
SELECT PRODUCT_CODE
FROM #no_stock
WHERE EXISTS
(SELECT * from NO_STOCK INNER JOIN #no_stock
ON NO_STOCK.PRODUCT_CODE = #no_stock.PRODUCT_CODE
WHERE NO_STOCK.PRODUCT_CODE = #no_stock.PRODUCT_CODE)
Run Code Online (Sandbox Code Playgroud)
PS.使用SQL Server 2008 R2
由于局部变量也称为自动变量,并且在访问函数时应该在运行时分配内存.
int main(){
int a; // declaration
return 0;
}
int main(){
int a[]; // compilation error, array_size missing
return 0;
}
int main(){
int a[2]; // declaration, but can't work without array_size,
// so at compile time it is checked!
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我的问题是,在C中声明中给出array_size是一个规则,还是在编译时为数组分配内存(仍然是本地变量)
它是如何工作的?
根据K&R的C编程,数组是一个变量.第161号.
我找到了一些代码来计算Levenshtein在答案和猜测之间的距离:
int CheckErrors(string Answer, string Guess)
{
int[,] d = new int[Answer.Length + 1, Guess.Length + 1];
for (int i = 0; i <= Answer.Length; i++)
d[i, 0] = i;
for (int j = 0; j <= Guess.Length; j++)
d[0, j] = j;
for (int j = 1; j <= Guess.Length; j++)
for (int i = 1; i <= Answer.Length; i++)
if (Answer[i - 1] == Guess[j - 1])
d[i, j] = d[i - 1, j …Run Code Online (Sandbox Code Playgroud) 我正在学习C++.我在格式化程序输出时遇到问题.我想打印完全对齐的列,但到目前为止我不能这样做,这是我的代码:
int main()
{
employee employees[5];
employees[0].setEmployee("Stone", 35.75, 053);
employees[1].setEmployee("Rubble", 12, 163);
employees[2].setEmployee("Flintstone", 15.75, 97);
employees[3].setEmployee("Pebble", 10.25, 104);
employees[4].setEmployee("Rockwall", 22.75, 15);
printEmployees(employees, 5);
return 0;
}
// print the employees in my array
void printEmployees(employee employees[], int number)
{
int i;
for (i=0; i<number; i++) {
employees[i].printEmployee();// this is the method that give me problems
}
cout << "\n";
}
Run Code Online (Sandbox Code Playgroud)
在班级员工中我有print员工方法:
void printEmployee() const
{
cout << fixed;
cout << surname << setw(10) << empNumber << "\t" << setw(4) << …Run Code Online (Sandbox Code Playgroud) 我正在尝试用sphinx来记录我的一个项目.我在所有模块和文件中都使用了autodoc字符串.我使用sphinx-apidoc rst为我的代码自动生成文件.到现在为止还挺好.
问题是sphinx无法导入我的任何模块,即使我已经添加了我的项目sys.path.
我的单元测试通过,可以导入我的模块就好了.我的智慧结束了; 我已经尝试了各种重命名和移动,重新加载和重新配置而没有成功,至少可以说非常令人沮丧.
这是我的文档结构:
project
??? collectionprocessor.py
??? config.py
??? createdb.py
??? database
? ??? database.py
? ??? __init__.py
??? docs
? ??? _build
? ??? conf.py
? ??? generated
? ??? index.rst
? ??? Makefile
? ??? modules.rst
? ??? project.database.rst
? ??? project.document.rst
? ??? project.mixins.rst
? ??? project.parser.rst
? ??? project.rst
? ??? project.sequence.rst
? ??? project.tests.rst
? ??? _static
? ??? _templates
??? document
? ??? document.py
? ??? …Run Code Online (Sandbox Code Playgroud) 考虑以下C++ 11代码:
#include <thread>
#include <vector>
struct A {
A() {}
//virtual ~A() = default;
//~A() = default;
//~A() {};
std::thread t;
};
int main()
{
std::vector<A> v;
v.emplace_back();
}
Run Code Online (Sandbox Code Playgroud)
如果取消注释前面代码中声明析构函数的任何行,则不会编译此代码.编译器抱怨std::thread被删除的复制construtor .但是std::vector::emplace_back应该不使用复制构造函数,那么,它为什么会失败?为什么提到析构函数很重要?
GCC输出(未~A() {};注释):
$ g++ --std=c++11 -o test test.cpp
In file included from /usr/include/c++/4.8/memory:64:0,
from /usr/include/c++/4.8/thread:40,
from test.cpp:1:
/usr/include/c++/4.8/bits/stl_construct.h: In instantiation of ‘void std::_Construct(_T1*, _Args&& ...) [with _T1 = A; _Args = {A}]’:
/usr/include/c++/4.8/bits/stl_uninitialized.h:75:53: required from ‘static _ForwardIterator std::__uninitialized_copy<_TrivialValueTypes>::__uninit_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator …Run Code Online (Sandbox Code Playgroud) 我希望将Dictionary设置为'Observable',以便在其项目更改时删除事件(删除或添加).
在其他类中我创建了这样的字典并将Binding设置为ListBox.ItemsSourseProperty.
绑定工作得很好.我可以看到这些物品.
但是出了点问题:事件PropertyChanged总是空的.
有人可以帮忙吗?
提前致谢!
class ObservableDictionary<TKey, TValue> :
Dictionary<TKey, TValue>,
INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
public new void Remove(TKey obj)
{
base.Remove(obj);
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs("Remove"));
}
}
}
Run Code Online (Sandbox Code Playgroud) 通过Project Euler试图学习F#,我在为问题3编写解决方案时偶然发现了类似推断问题.
这是我写的:
let rec findLargestPrimeFactor p n =
if n = 1 then p
else
if n % p = 0 then findLargestPrimeFactor p (n/p)
else findLargestPrimeFactor (p+1) n
let result = findLargestPrimeFactor 2 600851475143L
Run Code Online (Sandbox Code Playgroud)
但是,编译器给出了以下错误:
error FS0001: This expression was expected to have type int but here has type int64
由于我希望从使用中findLargestPrimeFactor推断出使用的类型,我很惊讶地发现编译器似乎假设参数n是一个int,因为在函数的唯一调用是用int64完成的.
有人可以向我解释一下:
我需要将 a 写BufferedImage为 .png 且不执行压缩。我环顾四周,并提出了以下代码。
public void save(String outFilePath) throws IOException {
Iterator<ImageWriter> iter = ImageIO.getImageWritersByFormatName("png");
ImageWriter writer = iter.next();
File file = new File(outFilePath);
ImageOutputStream ios = ImageIO.createImageOutputStream(file);
writer.setOutput(ios);
ImageWriteParam iwp = writer.getDefaultWriteParam();
iwp.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
iwp.setCompressionQuality(1.0f);
IIOImage image = new IIOImage(mapImage, null, null);
writer.write(null, image, iwp);
writer.dispose();
//ImageIO.write(mapImage, "png", file);
}
Run Code Online (Sandbox Code Playgroud)
这是抛出的异常。
Exception in thread "main" java.lang.UnsupportedOperationException: Compression not supported.
at javax.imageio.ImageWriteParam.setCompressionMode(Unknown Source)
at Map.MapTransformer.save(MapTransformer.java:246)
at Map.MapTransformer.main(MapTransformer.java:263)
Run Code Online (Sandbox Code Playgroud) 我想知道是否有可能CountDownTimer无限重复?
我想做一个盲测,当计时器退出并用另一首歌重启时,它会改变歌曲.
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.jeu);
int timeinminutes=1;
new CountDownTimer(timeinminutes*21000, 1000)
{
TextView jeutimer = (TextView) findViewById(R.id.jeu_timer);
public void onTick(long millisUntilFinished)
{
long scnds=0;
scnds=(millisUntilFinished/1000);
jeutimer.setText( "" + scnds);
}
public void onFinish()
{
}
}.start();
Run Code Online (Sandbox Code Playgroud)
我的问题是没有"重启"功能,我想无限地重新开始我的倒计时