小编Nic*_*ick的帖子

如何通过网页将参数传递到PHP脚本?

每当网页加载时我都会调用PHP脚本.但是,有一个PHP脚本需要运行的参数(我通常在测试脚本时通过命令行).

每次在页面加载时运行脚本时,如何传递此参数?

php parameters

137
推荐指数
2
解决办法
22万
查看次数

如何改进此算法以防止TLE是SPOJ提交?

我试图解决以下问题:http: //www.spoj.pl/problems/TRIP/

我在C++中使用DP(动态编程)编写了一个解决方案(下面发布的代码).但我得到了TLE(时间限制超过).如何优化我的代码?

#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;
string a,b;
vector<string> v;
int dp[85][85];

void filldp()
{
    for(int i = 0; i <= a.length(); i++)
        dp[i][0] = 0;
    for(int i = 0; i <= b.length(); i++)
        dp[0][i] = 0;   

    for(int i = 1; i <= a.length(); i++)
        for(int j = 1; j<= b.length(); j++)
        if(a[i-1] == b[j-1])
            dp[i][j] = dp[i-1][j-1] + 1;
        else
            dp[i][j] = max(dp[i-1][j], dp[i][j-1]); 
}

vector<string> fillv(int i, int j) …
Run Code Online (Sandbox Code Playgroud)

c++ algorithm dynamic-programming data-structures

6
推荐指数
1
解决办法
2052
查看次数

什么类型的字符串是C字符串函数的合法输入?

做相同功能strcatstrcmp需要空终止字符串作为参数,或者是任何字符的阵列上可接受的?

所有文档都表明它必须以空值终止,但最着名的在线参考之一(http://cplusplus.com)给出以下示例strcmp:

/* strcmp example */
#include <stdio.h>
#include <string.h>

int main ()
{
  char szKey[] = "apple";
  char szInput[80];
  do {
     printf ("Guess my favourite fruit? ");
     gets (szInput);
  } while (strcmp (szKey,szInput) != 0);
  puts ("Correct answer!");
  return 0;
}
Run Code Online (Sandbox Code Playgroud)

c string

3
推荐指数
1
解决办法
200
查看次数

SPOJ问题 - 这里出了什么问题?

我正在回答这个问题:http: //www.spoj.pl/problems/JAVAC/

我用C++编写了提交的代码.我在下面粘贴它.提交一直给出错误的答案.我找不到一个失败的测试用例.谁能帮我吗 ?

非常感谢.

#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

char *ans;

bool iscapital(char c)
{
  if(c >='A' && c <='Z')
    return true;
  else
    return false;
}

string translate(string current)
{ 
  ans = new char[2*current.length() + 1];
  int jflag = 0, cflag = 0,j = 0, i = 0;

  if(iscapital(current[0]))
  {
    return "Error!";
  }

  while(i < current.length())
  {
    if(current[i] !='_')
    {
      if(!(current[i] >= 'A' && current[i] <= 'Z'))
      {
    ans[j] = current[i];
    i++;
    j++;
      }
    }

    if(current[i] …
Run Code Online (Sandbox Code Playgroud)

c++ java algorithm

2
推荐指数
1
解决办法
1009
查看次数

在unix中区分b/w exec()和system()

基于unix的系统中命令exec(const char*c)和system(const char*c)之间的区别是什么?

两者都可以从C程序调用来执行系统调用.这两个有没有区别?

c unix system exec

2
推荐指数
1
解决办法
2883
查看次数