比如我们要定义一个下标从 -1000 到 1000 (闭区间)的 int 类型数组,我们可以这样写:
int *a = new int[2001] + 1000;
import numpy as np | |
import math | |
def process_number(s): | |
s = s.replace(',', '') | |
if s[-1] == '\n': | |
s = s[:-1] | |
if s[-1] == '%': | |
return float(s[:-1]) * 0.01 | |
return float(s) |
#include <cstdint> | |
#include <iostream> | |
#include <opencv2/opencv.hpp> | |
#define TEST_FILE(x) "../" x | |
template <typename Num> | |
inline Num sq(Num x) { return x * x; } | |
cv::Mat convolveDFT(const cv::Mat &image, const cv::Mat &stencil) { |
// This script works well with Photoshop CC 2017 | |
// Adopted from stackoverflow.com/questions/14571008/photoshop-scripting-changing-text-of-a-text-layer | |
Array.prototype.forEach = function (fn) { | |
for (var i = 0; i < this.length; i++) { | |
fn(this[i], i); | |
} | |
}; | |
var doc; |
#include <stdlib.h> | |
#include <stdio.h> | |
#include <ctype.h> | |
#include <string.h> | |
#define BUFFER_SIZE 256 | |
int value(); | |
int integer(); | |
int factor(); |
# coding: utf-8 | |
from requests import request | |
from bs4 import BeautifulSoup as bs | |
from pyquery import PyQuery as pq | |
from time import sleep | |
import json | |
import re | |
import MySQLdb |
#include "cstdio" | |
#include "iostream" | |
#include "algorithm" | |
#include "cmath" | |
#include "cstring" | |
#include "ctime" | |
#include "cstdlib" | |
#include "vector" | |
#include "queue" | |
#include "set" |
#include <cstdio> | |
#include <cstdlib> | |
#include <vector> | |
const int N = 100000, TREE_HEIGHT = 17; | |
struct point { | |
long long x, y; | |
int multi(const point &a, const point &b) { | |
// printf("Multiply a(%d, %d) with b(%d, %d)", |
#include <iostream> | |
#include <vector> | |
const int MAX = 2000000; | |
bool is_prime[MAX + 1] = { 0 }; | |
std::vector<int> primes; | |
int main() { | |
is_prime[2] = true; |