问候,堆栈溢出
在我的数据库中,我已经有一个表,"联系人",其中包含个人的记录.我的数据库中还有其他几个表,它们代表包含表示特定技能的记录的"技能组".
1)我是否正确地将其视为"多对多"关系?(每个联系人可以有多个技能组,每个技能组可以属于多个联系人)
2)我是数据库的新手 - 我想链接表吗?
3)有没有在我的计划(C来实现此#+ Windows窗体),使得在"联系人"表中的任何给定的记录,无论是所有相关的"技能"表的名称的方法或所有的"技能"记录相关联可以检索"联系人"记录吗?
(数据库位于SQL Server Express 2008上.通过VisualStudio 2008内置的"数据连接向导"从数据库中检索数据)
问候.
我的任务是调试涉及正则表达式的应用程序的一部分 - 但是,我之前从未处理过Regex.两个问题:
1)我知道正则表达式应该测试两个字符串是否相同,但下面的两个正则表达式具体用什么来表示普通英语?
2)有没有人对我可以了解更多有关正则表达式的网站/来源有什么建议?(最好是在C#中)
if (Regex.IsMatch(testString, @"^(\s*?)(" + tag + @")(\s*?),", RegexOptions.IgnoreCase))
{
result = true;
}
else if (Regex.IsMatch(testString, @",(\s*?)(" + tag + @")(\s*?),", RegexOptions.IgnoreCase))
{
result = true;
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试在Eclipse中编写一个"Hello,World"变体程序,我似乎无法运行我的程序.
这是代码:
/**
*
*/
package GreeterPackage;
/**
* @author Raven Dreamer
* Prints out "Hello, World" in three languages:
* English, French, and Spanish.
*/
public class GreeterProg {
/**
* returns "Hello, World" three times, once
* in English, once in French, and once in
* Spanish.
*/
public static void Main(String[] args){
/** instances of the three greeter
* classes so the non-static methods
* can be called.
*/
EnglishGreeter eng = new EnglishGreeter();
FrenchGreeter fre = …Run Code Online (Sandbox Code Playgroud) 我发现自己需要为我的软件工程课学习一点JSP.我们的一个功课问题如下:
What are the output of these two code snippets if the parameter "myText" has the
value "JSP is fun"?
<% request.getParameter("myText"); %>
...and...
<%= request.getParameter("myText") %>
Run Code Online (Sandbox Code Playgroud)
这是我的答案:
第一行代码片段应正确返回"JSP is Fun".
第二行代码也应正确返回"JSP is Fun",因为它是一个表达式,这意味着它不需要使用分号来正常运行(并且不能使用分号).
我错过了一些明显的东西,或者这个相对简单的问题真的没有了吗?
由于这是一个令人敬畏的意外特征,它使得"洗牌"一系列"卡片"变得糟糕.我得到相同数字的事实告诉我,每次采摘单独的种子时我都遇到了一些问题.我使用srand48或time(NULL)拨打电话不正确吗?我缺少一些潜在的逻辑漏洞吗?在迭代之间没有足够的时间来使值time()不同吗?
代码正在Linux上运行.
void shuffle()
{
int i_rnd; /* Integer random number, range 0..100 */
int i_rnd2;
card tempCard; /*temporary card to facillitate swapping*/
int i = 0; /*can't use a FOR loop 'cause we're not using c99 standard*/
while(i < 1000)
{
srand48( (unsigned) time( NULL ) ); /* Seed the random number generator */
i_rnd = (int) ( drand48() * 100);
i_rnd = i_rnd%52; // return a random number 0-51
i_rnd2 = (int) …Run Code Online (Sandbox Code Playgroud) 下面的程序解析了一个所谓的Dwarf Fortress的 RAW文件.代码工作正常,但是对于我当前的实现,我需要为每个文件运行一次程序,每次手动更改源文件.有没有我可以改为解析给定文件夹中的所有文本文件?
(请注意,当前输出文件与输入文件位于同一个文件夹中.我不太确定如果程序试图打开文件时会发生什么情况,但是这是有意义的.心神).
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
// create reader & open file
string filePath = @"C:\foo\Dwarf Fortess\creature_domestic.txt";
string destPath = @"C:\foo\Dwarf Fortess\eggCreatures.txt";
string line;
//
TextReader tr = new StreamReader(filePath);
TextWriter tw = new StreamWriter(destPath);
// read a line of text
while ((line = tr.ReadLine()) != null)
{
if (line.Contains("[CREATURE:"))
{
tw.WriteLine(line);
}
if(line.Contains("[LAYS_EGGS]"))
{
tr.ReadLine();
tr.ReadLine();
tr.ReadLine(); …Run Code Online (Sandbox Code Playgroud) 我对11月7日感到愤怒.
我已经写了一个方法来计算两个Java Date对象之间的天数(在它被提到之前,JodaTime不是一个选项) - 该方法在大多数情况下工作,但是当白天开始xor结束日期时节省时间,产量减少一天.
压延机是否有某种方法可以覆盖日期的时区?我不关心日期实际上是什么时区,但它们必须是同一个!
代码如下:
public int getDayRange() {
//startDate = "Sat Nov 06 00:00:00 EDT 2010";
//endDate = "Sun Nov 07 23:59:59 EST 2010";
TimeZone tz = TimeZone.getTimeZone("UTC");
GregorianCalendar cal1 = new GregorianCalendar(tz);
GregorianCalendar cal2 = new GregorianCalendar(tz);
cal1.setTime(startDate);
cal2.setTime(endDate);
long ms1 = cal1.getTime().getTime();
long ms2 = cal2.getTime().getTime();
long difMs = ms2-ms1;
long msPerDay = 1000*60*60*24;
double days = difMs / msPerDay;
return (int) Math.floor(days)+1;
//returns 3(!!!) days (wrong)
}
Run Code Online (Sandbox Code Playgroud)