Skip to content

Instantly share code, notes, and snippets.

string S = "パタトクカシーー"
cout << S[0] // "パ"ではなく文字化けが表示される
// 3バイト分取得すればOKだった
size_t one_char = 3;
cout << S.substr(0, one_char); // "パ"
## 最初に入力回数が与えられて、そのあとデータが入力される。といったパターン
N = int(input())
a = []
for i in range(N):
a.append(input()) # 3度の入力に対して、1, 2, 3 と入力。
print(a) # ['1', '2', '3']
## 内包表記だとベター
N = int(input())
a = [input() for i in range(N)]
# 1行の入力データを分割
data = input().split() # "1 2 3"と入力
print(data) #['1', '2', '3']
print(data[0]) # 1
print(type(data[0])) # str
# 入力データの数値化
nums = list(map(int, input().split())) # "1 2 3"と入力
## Python3では、listを使う必要がある。mapはリストを返す仕様ではなくなったため。
## 入力は文字列として扱われる。
print(type(input())) # str
## 数値へと型変換。
print(type(int(input()))) # int
# 単純入力
## Python3では、raw_inputは廃止された。inputを用いる。
S1 = input()
# 単純出力
print("aaa") # aaa
## Python2では print "aaa"だったが、3ではカッコが必要。
#include <iostream>
using std::cin;
using std::cout;
using std::string;
using std::endl;
int main() {
string sameChars = "aaa";
string notSameChars = "abab";
'use strict'
var thinky = require('thinky')({
host: 'localhost',
port: 28015,
db: 'People'
})
var r = thinky.r
// By Calling thinky the connection pool will be created
const thinky = require('thinky')() // "Creating a pool connected to localhost:28015"
const type = thinky.type
// We can use reference to the RethinkDB driver
const r = thinky.r
r.now().run().then((time) => {
return time // 2016-09-19T05:22:53.098Z (example)
})
module.exports = {
rethinkdb: {
host: 'localhost',
port: 28015,
authKey: '',
db: 'rethinkdb_ex'
},
express: {
port: 3000
}
const r = require('rethinkdb')
const express = require('express')
const async = require('async')
const bodyParser = require('body-parser')
const config = require(__dirname + '/config')
const app = express()
// index.htmlとその他のフロントエンドアセットをサーブする。