我有一张简单的桌子
CREATE TABLE a(
id int IDENTITY(1,1) NOT NULL,
x varchar(50)
)
Run Code Online (Sandbox Code Playgroud)
我发现以下查询有效
select cast (id as varchar(3))+cast (x as varchar(3)) c from a
where cast (id as varchar(3))+cast (x as varchar(3))='1a'
Run Code Online (Sandbox Code Playgroud)
但这不起作用
select cast (id as varchar(3))+cast (x as varchar(3)) c from a
where c='1a'
Run Code Online (Sandbox Code Playgroud)
有人知道那是为什么吗?请不要因为某些原因我不想使用
where id=1 and x ='a'
Run Code Online (Sandbox Code Playgroud) 我一直在研究java中基于文本的RPG,只是为了好玩.经过几个小时的繁琐工作,我写了几十个课程,用于武器,咒语,cmbat系统,购物系统等.我写了一个简单的课程来开始和运行游戏.所有它真正做的是显示一个主菜单,并创建一个对象,反过来创建游戏中的每个类,并开始一个新的游戏.RunGame类的代码如下:
import java.util.Scanner;
import java.util.Random;
public class RunGame {
public static void main(String []args) {
Scanner reader = new Scanner(System.in);
int choice = 0;
QueratiaMain main = new QueratiaMain(); //code stops responding after creation of this object. why?
// reader.nextLine();
System.out.println("Welcome to Queratia, a text-based RPG! Choose an option:\n1. Start New Game\n2. Exit");
choice = reader.nextInt();
if(choice == 1) {
}else
System.exit(99);
}
}
Run Code Online (Sandbox Code Playgroud)
一切都编译得很好,但是当我运行程序时,代码似乎停止在我创建QueratiaMain对象的任何行上进行.有什么想法为什么会这样做?谢谢!
更新:调试代码后,我得到了几行调试器告诉我没有找到源代码,并且某些行抛出了一个未找到的文件异常.但是,我正在Eclipse中的正常工作区工作,那么这怎么可能呢?我试图手动指定在哪里找到文件,但没有改变.关于为什么会发生这种情况的任何想法?
我有一个UITableView通过CoreData填充,并且刚刚注意到一些奇怪的东西.我在UITable中大约有20行,当我向下滚动表并再次向上时,单元格的标签会被写在现有文本的顶部,并且每次我再次向上和向上时都会继续执行.我的代码CellForRowAtIndexPath是:
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
//Some constants ---
const NSInteger TOP_LABEL_TAG = 1001;
const NSInteger BOTTOM_LABEL_TAG = 1002;
UILabel *topLabel;
UILabel *bottomLabel;
const CGFloat LABEL_HEIGHT = 20;
//CGRect Imageframe = CGRectMake(7, 5, 35, 35);
//----
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
cell.textLabel.font = [UIFont …Run Code Online (Sandbox Code Playgroud) 我只是想知道,是否可以在类构造时立即创建类的数组成员:
class C
{
public:
C(int a) : i(a) {}
private:
int i;
};
class D
{
public:
D() : a(5, 8) {}
D(int m, int n) : a(m,n) {}
private:
C a[2];
};
Run Code Online (Sandbox Code Playgroud)
就我用Google搜索而言,构造函数中的数组创建(如上所述)在C++中是不可能的.或者,可以在构造函数块中如下初始化阵列成员.
class D
{
public:
D() {
a[0] = 5;
a[1] = 8;
}
D(int m, int n) {
a[0] = m;
a[1] = n;
}
private:
C a[2];
};
Run Code Online (Sandbox Code Playgroud)
但是,它不再是一个数组创建,而是数组赋值.数组元素由编译器通过其默认构造函数自动创建,随后将它们手动分配给C'tor块中的特定值.什么令人讨厌; 对于这样的解决方法,C类必须提供默认的构造函数.
有没有人知道哪些可以帮助我在构建时创建阵列成员.我知道使用std :: vector可能是一个解决方案但是,由于项目条件,我不允许使用任何标准,Boost或第三方库.
我想将两个矩阵相乘,但三重循环具有O(n 3)复杂度.在动态编程中是否存在将两个矩阵与O(n)复杂度相乘的算法?
好吧我们不能得到最好的O(n 2.81)
编辑:但有没有任何解决方案甚至可以将结果逼近某些特定的否.列和行的矩阵
我的意思是我们得到O(n 2.81)中最好的一个复杂的解决方案,但结果很完美,但是如果有任何解决方案甚至近似矩阵的乘法,因为我们有因子近似等公式.
如果有任何你知道它会帮助我
问候.
我知道这段代码是对的:
class A:
def __init__(self):
self.a = 'a'
def method(self):
print "method print"
a = A()
print getattr(a, 'a', 'default')
print getattr(a, 'b', 'default')
print getattr(a, 'method', 'default')
getattr(a, 'method', 'default')()
Run Code Online (Sandbox Code Playgroud)
这是错的:
# will __getattr__ affect the getattr?
class a(object):
def __getattr__(self,name):
return 'xxx'
print getattr(a)
Run Code Online (Sandbox Code Playgroud)
这也是错的:
a={'aa':'aaaa'}
print getattr(a,'aa')
Run Code Online (Sandbox Code Playgroud)
我们应该在哪里使用这些功能(__getattr__和getattr)?
我有一个汽车分类列表数据库.
90天后,分类列表不再有效显示(列表过期); 但是,我想保留列表以便存档.
问题:从数据库设计最佳实践角度以及查询性能来看,最好将旧的列表A)与当前列表保持在同一个表中,或者B),将过期的列表移到过期的表中并删除该列表从目前的上市表?
换一种说法,
选项A):
table_classified_listing:
car_id
expired = true | false
...
Run Code Online (Sandbox Code Playgroud)
选项B):
// only current listing in this table (expired = false)
table_classified_listing:
car_id
...
// only expired listing in this table (expired = true)
expired_table_classified_listing:
car_id
...
Run Code Online (Sandbox Code Playgroud)
更新:
我对选项A的关注是,在我的MySQL数据库中 - 当我运行时EXPLAIN,它说它正在使用expired作为索引的主键.但是,对我的查询搜索性能更重要的是它使用该price字段,因为我正在进行基于的搜索price > X.因此我为什么考虑选择选项B.
当我试图通过PHPMailer发送邮件时,我收到此错误消息.我的代码如下:
<?
require("phpmailer/class.phpmailer.php"); // First we require the PHPMailer libary in our script
$mail = new PHPMailer(); // Next we create a new object of the PHPMailer called $mail
$mail->From = "rajasekar.kcet@gmail.com";
$mail->FromName = "Rajasekar";
$mail->AddAddress("rajasekar.kcet@gmail.com"); // This is the adress to witch the email has to be send.
$mail->Subject = "First PHP Email message"; // This is the subject of the email message.
$mail->Body = "Hi! \n\n This is my first e-mail sent through PHP."; // This is the …Run Code Online (Sandbox Code Playgroud) 我正在使用我们使用标准ControlTemplates创建的自定义Scrollbars,但是当我将它们应用到ListBox时,右下角有一个角落,我无法找到任何覆盖方式.
不幸的是,在我获得更多分数之前,我无法发布图片.但我所指的角落是当垂直和水平滚动条都出现时,右下方有一个空间,里面充满了灰白色的颜色,我无法消除