我写了一个c ++程序,我想知道如何计算执行时间,所以我不会超过时间限制.
#include<iostream>
using namespace std;
int main ()
{
int st[10000],d[10000],p[10000],n,k,km,r,t,ym[10000];
k=0;
km=0;
r=0;
scanf("%d",&t);
for(int y=0;y<t;y++)
{
scanf("%d",&n);
for(int i=0;i<n;i++)
{
cin>>st[i] >>d[i] >>p[i];
}
for(int i=0;i<n;i++)
{
for(int j=i+1;j<n;j++)
{
if((d[i]+st[i])<=st[j])
{
k=p[i]+p[j];
}
if(k>km)
km=k;
}
if(km>r)
r=km;
}
ym[y]=r;
}
for( int i=0;i<t;i++)
{
cout<<ym[i]<<endl;
}
//system("pause");
return 0;
}
Run Code Online (Sandbox Code Playgroud)
这是我的节目,我希望它在3秒的时限内!怎么做 ?是的,我的意思是执行时间!!
我正在重建我在WPF视频的可下载代码中找到的WPF幻灯片放映应用程序结构.
有一个Presentation类,它具有一个INotifyPropertyChanged属性"CurrentSlide",当您单击下一个/上一个按钮时它会发生变化,并在Frame元素中动态显示.
下载的代码将Pages加载到此框架中,但我尝试加载UserControls似乎也能正常工作,实际上我找不到任何区别.
有没有人知道将Pages或UserControl加载到XAML Frame元素中的任何差异?
<Window x:Class="TestFull8229.Views.MainView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:c="clr-namespace:TestFull8229.Commands"
xmlns:viewModels="clr-namespace:TestFull8229.ViewModels"
Title="Main Window" Height="400" Width="800">
<Window.Resources>
<viewModels:Presentation x:Key="presentation"/>
</Window.Resources>
<DockPanel>
<StackPanel>
<Viewbox Stretch="Uniform">
<Frame Width="800" Height="600"
Source="{Binding Path=CurrentSlide,
Source={StaticResource presentation}}"/>
</Viewbox>
</StackPanel>
</DockPanel>
</Window>
Run Code Online (Sandbox Code Playgroud) 这是正确的,它可以正常工作
string str("in.dat");
ifstream fin(str.c_str(), ios::binary | ios::ate );
.
.
.
//Do I need to clear the string before assigning new name???
str = "out.dat";
ofstream fout(str.c_str(), ios::binary); //seems to work
Run Code Online (Sandbox Code Playgroud)
问候
我有一个包含三个表的数据库:userid_tbl,need_tbl,have_tbl
create table userid_tbl
(user_id varchar2(15) not null primary key);
create table need_tbl
(user_id varchar2(15) not null,
have_item varchar2(100) not null,
foreign key (user_id) references userid_tbl (user_id)
);
create table have_tbl
(user_id varchar2(15) not null,
have_item varchar2(100) not null,
foreign key (user_id) references userid_tbl (user_id)
);
Run Code Online (Sandbox Code Playgroud)
每个用户都可以创建无限数量的他们可以提供给数据库中其他人的需求或服务的记录.这些项目来自预定的清单.
在对需求和表进行连接之后,我已经满足了需求和需求,并丢弃了在以下视图中任何用户无法满足的请求:
Item: Need: Have:
1 Bob George
2 George Herbie
3 Herbie Bob
4 Larry Wally
5 Wally Larry
6 John George
Run Code Online (Sandbox Code Playgroud)
我现在正在尝试编写一个查询,在那里我可以计算满足所请求需求的每个用户的排列数.例如,在上面的例子中,鲍勃,乔治和赫比可以一起满足彼此的需要,拉里和沃利也可以,但约翰不能,所以总数将是2.
我首先开始使用LOOP执行此操作,但必须使用单个查询来执行此操作的更简单,资源更少的方法.
哪个在散列表或排序列表中找到项目更快?
我有以下几行:
Message:Polarion commit Mon May 18 06:59:37 CEST 2009
Message:Polarion commit Fri May 15 19:39:45 CEST 2009
Message:424-18: use new variable
Message:Polarion commit Fri May 15 19:29:10 CEST 2009
Message:Polarion commit Fri May 15 19:27:23 CEST 2009
Message:000-00: do something else
Message:Polarion commit Fri May 15 17:50:30 CEST 2009
Message:401-103: added application part
Message:Polarion commit Fri May 15 17:48:46 CEST 2009
Message:Polarion commit Fri May 15 17:42:04 CEST 2009
Run Code Online (Sandbox Code Playgroud)
我希望得到所有不包含"Polarion"的行
我该怎么做?
ps:我看到:正则 表达式匹配的东西不是特定的子字符串, 但它对我没有帮助
pps:我正在尝试在tortoiseSVN中选择日志消息,我认为"负面看后"存在问题
假设我有以下课程:
public class FixExpr {
Expr<FixExpr> in;
}
Run Code Online (Sandbox Code Playgroud)
现在我想介绍一个泛型参数,抽象使用Expr:
public class Fix<F> {
F<Fix<F>> in;
}
Run Code Online (Sandbox Code Playgroud)
但Eclipse并不喜欢这样:
F型不是通用的; 它不能用参数<Fix <F >>进行参数化
这是可能的还是我忽略了导致这个特定实例破坏的东西?
一些背景信息:在Haskell中,这是编写泛型函数的常用方法; 我正在尝试将其移植到Java.上例中的类型参数F具有类型* - >*而不是通常的类型*.在Haskell中它看起来像这样:
newtype Fix f = In { out :: f (Fix f) }
Run Code Online (Sandbox Code Playgroud) 我必须修改一个大型PHP应用程序的某些部分.当然,不同的部分是由不同的人(主要是实习生)编写的.查看代码后,我发现其他开发人员使用了2种编码样式:
[剪断]
<tr class="ds_subsubhead_2">
<td colspan="21" align="left"> A <select name="nb_linge" onChange="MM_jumpMenu('parent',this,0)" style="vertical-align:middle"> <option value="<?=get('index.php',$orgurl,'nb_ligne=','22','23','9999') ?>" <? if($messagesParPage == '9999') { ?>selected="selected"<? } ?>>Tous</option>
<option value="<?=get('index.php',$orgurl,'nb_ligne=','22','23','25') ?>" <? if($messagesParPage =='25') { ?>selected="selected"<? } ?>>25</option>
<option value="<?=get('index.php',$orgurl,'nb_ligne=','22','23','50') ?>" <? if($messagesParPage =='50') { ?>selected="selected"<? } ?>>50</option>
<option value="<?=get('index.php',$orgurl,'nb_ligne=','22','23','75') ?>" <? if($messagesParPage =='75') { ?>selected="selected"<? } ?>>75</option>
Run Code Online (Sandbox Code Playgroud)
[snip]或
<td <? if((isset($_GET['t1']))&&($_GET['t2']!='ALL')) { ?>bgcolor="#0099FF"<? } ?>></td>
<td <? if((isset($_GET['t3']))&&($_GET['t4']!='ALL')) { ?>bgcolor="#0099FF"<? } ?>></td>
<td <? if((isset($_GET['t5']))&&($_GET['t6']!='ALL')) { ?>bgcolor="#0099FF"<? } ?>></td>
Run Code Online (Sandbox Code Playgroud)
[剪]甚至
<script type="text/javascript" src="<?=$_SESSION["path"]?>lib/js/ajax.js"></script>
Run Code Online (Sandbox Code Playgroud)
[剪断]
我发现在使用NHibernate并在一个对象上创建一对多的关系时,当许多变得非常大时,它会显着减慢.现在我在我的存储库中有方法来收集该类型的分页IList,但是我更喜欢在模型上使用这些方法,因为这通常是其他开发人员首先要收集子对象列表的地方.
例如
RecipientList.Recipients将返回列表中的每个收件人.
我想实现一种方法,在我的模型中使用优选的接口添加对我的所有关系的分页,但实际上任何不会强制键入模型的关系.例如,拥有以下界面会很不错:
public interface IPagedList<T> : IList<T>
{
int Count { get; }
IList<T> GetPagedList(int pageNo, int pageSize);
IList<T> GetAll();
}
Run Code Online (Sandbox Code Playgroud)
然后能够在代码中使用它...
IList<Recipient> recipients = RecipientList.Recipients.GetPagedList(1, 400);
Run Code Online (Sandbox Code Playgroud)
我一直试图想办法做到这一点,而不给模型任何分页意识,但我现在正撞在一堵砖墙上.
无论如何我可以用NHibernate为IList和lazyloading做的类似方式实现接口吗?我对NHibernate知之甚少知之甚少.
实现这个甚至是个好主意吗?您的想法将被认为是内部唯一的.NET开发人员,我没有人可以反复提出想法.
UPDATE
下面的帖子向我指出了NHibernate的自定义集合属性,它可以很好地工作.但是我不确定最好的解决方法是什么,我试图从PersistentGenericBag继承,以便它具有与IList相同的基本功能而没有太多工作,但是我不确定如何基于ISessionImplementor收集对象列表.我需要知道如何:
但是我不确定我是否可以做以上任何一种情况?
谢谢
我的viewpage没有代码隐藏,那么如何告诉它使用强类型的viewdata呢?
c++ ×2
algorithm ×1
asp.net ×1
asp.net-3.5 ×1
asp.net-mvc ×1
c# ×1
generics ×1
hashtable ×1
haskell ×1
interface ×1
java ×1
lookup ×1
nhibernate ×1
oracle ×1
performance ×1
php ×1
polymorphism ×1
regex ×1
sortedlist ×1
sql ×1
string ×1
tortoisesvn ×1
viewdata ×1
wpf ×1
xaml ×1