我正在关注PHP-MySQL shoutbox教程,该教程仅涉及在数据库中发送和存储消息.完成之后,我暂时选择每隔5秒刷新一次消息列表,或者每次使用AJAX发送新消息时刷新消息列表.但在实际应用中,这将是效率太低且服务器消耗(实际上是低强度DDOS).那么如何在必要时刷新新邮件列表?更准确地说,如何在发生这种情况时通知我发送了新消息,以便我可以显示它?
大家好我基本上都在尝试使用zlib库,但是当我尝试给自我放气的文件充气时我遇到了麻烦,尽管当我给其他zlib文件充气时它工作正常.
压缩代码:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef unsigned char BYTE;
typedef unsigned int UINT;
#include "zlib.h"
#define HEADERSIZE (1024)
#define CHUNKSIZE 4096
#define SWAPINT(x) (((x)&0xFF) << 24)|(((x)&0xFF00) << 8) | (((x)&0xFF0000) >> 8) | (((x)&0xFF000000) >> 24)
#define DEFLATESIZE 65536
const char *mz_error(int err)
{
static struct { int m_err; const char *m_pDesc; } s_error_descs[] =
{
{ Z_OK, "" }, { Z_STREAM_END, "stream end" }, { Z_NEED_DICT, "need dictionary" }, { Z_ERRNO, "file error" }, { Z_STREAM_ERROR, …Run Code Online (Sandbox Code Playgroud) 我试图解决项目euler 31:
在英格兰,货币由英镑,英镑和便士p组成,一般流通中有八个硬币:
1p,2p,5p,10p,20p,50p,£1(100p)和£2(200p).可以通过以下方式赚取2英镑:
1×£1 + 1×50p + 2×20p + 1×5p + 1×2p + 3×1p
使用任意数量的硬币可以制作多少种不同的方式?
使用此代码:
#define to2(x) ((x)/2+1)
int to5(x)
{
int acc=1;
for(;x>0;x-=5)
acc+=to2(x);
return acc;
}
int to10(x)
{
int acc=1;
for(;x>0;x-=10)
acc+=to5(x);
return acc;
}
int to20(x)
{
int acc=1;
for(;x>0;x-=20)
acc+=to10(x);
return acc;
}
int to50(x)
{
int acc=1;
for(;x>0;x-=50)
acc+=to20(x);
return acc;
}
int to100(x)
{
int acc=1;
for(;x>0;x-=100)
acc+=to50(x);
return acc;
}
int main()
{
int test = to100(200)+1;
printf("%d",test); …Run Code Online (Sandbox Code Playgroud)