kinyou
|
codepad
|
|
kinyou
|
Saved pastes by kinyou:
<?php
$arr = array('毛色:::黑,,,白,,,水粉','尺寸:::L,,,M,,,S');
$arr2 = array('毛色:::黑,,,白,,,水粉','尺寸:::L,,,M,,,S');
print_r($arr);
foreach($arr as $key=>$value){
|
view (17 lines, 55 lines of output) |
#include<stdio.h>
int main(void){
int arr[] = {3,45,23,56,12};
int i;
for(i=0;i<5;i++){
|
view (10 lines, 5 lines of output) |
#include<stdio.h>
#define FORMAT "%s! C is cool!\n"
int main(void){
int num=10;
printf(FORMAT,FORMAT);
|
view (10 lines, 5 lines of output) |
#include<stdio.h>
int main(void){
int res;
int tmp=3,tmp2=2,tmp3;
res = tmp+(tmp3=tmp2*tmp);
|
view (8 lines, 1 line of output) |
#include <stdio.h>
int main(void){
int n = 222222;
size_t intsize;
intsize = sizeof(int);
|
view (8 lines, 1 line of output) |
#include <stdio.h>
#include <limits.h> //整数的限制
#include <float.h> //浮点数的限制
int main(void){
|
view (16 lines, 9 lines of output) |
#include <stdio.h>
#include <limits.h> //整数的限制
#include <float.h> //浮点数的限制
int main(void){
|
view (15 lines, 8 lines of output) |
line = '210.128.158.121 - oadev [09/Sep/2014:12:01:20 +0900] "GET /images/home_image/img/15457/large.jpg HTTP/1.0" 200 0 179'
(@ip, @test, @test2, @time, @timelag, @method, @file) = line.split(nil)
MONTH = {'Jan'=>'1','Feb'=>'2','Mar'=>'3','Apr'=>'4','May'=>'5','Jun'=>'6','Jul'=>'7','Aug'=>'8','Sep'=>'9','Oct'=>10,'Nov'=>'11','Dec'=>'12'};
puts @file
year = @time[8,4]
|
view (13 lines, 5 lines of output) |
line='36.46.178.254 - oadev [09/Sep/2014:13:57:09 +0900] "GET /categ=0/login_id=110416/plan/ HTTP/1.1" 200 0 11363'
(@ip, @test, @test2, @time, @timelag, @method, @file) = line.split(nil)
puts @ip
puts @test
puts @test2
|
view (13 lines, 9 lines of output) |
<?php
$arr = array(
array("NAME"=>"order_mail_text","VAL"=>"sss"),
array("NAME"=>"order_mail_text","VAL"=>"ggg"),
array("NAME"=>"inquiry_mail_text","VAL"=>"df"),
|
view (26 lines, 6 lines of output) |
#给Block提供参数的方法
#Block块中的参数用两个|包括起来,如果有多个参数,它们之间用逗号分隔
def call_block
yield("hello","sdeepwang")
|
view (8 lines, 1 line of output) |
#ruby的正则
# 字符串 =~ 正则对象 操作符表示用正则表达来匹配左边的字符串,如果匹配返回匹配的位置,否则返回nil
line = 'my first language is php script'
|
view (12 lines, 1 line of output) |
#ruby的散列用法与数组相似但是定义不同于数组而是用花括号{}
list = {'name'=>'sdeepwang',1=>'demo','age'=>25}
#=>的左边是键,右边是其对应的值,在一个散列中键必须唯一,键和值可以是任意对象
|
view (7 lines, 2 lines of output) |
<?php
$month1_time = getDateAfterMonth('2014-08-15 14:34:18.808474+09',1);
echo $month1_time;
echo "\n";
|
view (17 lines, 2 lines of output) |
<?php /*为什么do while没有替换语法*/?>
<?php $i = 10 ;?>
<?php do:?>
<?php echo $i;$i--;?>
<?php enddo;?>
|
view (6 lines, 2 lines of output) |
<?php $i = 5;?>
<?php switch($i):?>
<?php case 1: echo "i am 1";break;?>
<?php case 2: echo "i am 2";break;?>
<?php case 3: echo "i am 3";break;?>
|
view (7 lines, 1 line of output) |
<?php $arr = range(0,10);?>
<?php foreach($arr as $key=>$value):?>
<?php echo $key."<----->".$value."\n";?>
<?php endforeach;?>
|
view (4 lines, 11 lines of output) |
<?php for($i = 0 ;$i < 10 ;$i++):?>
<?php if($i > 3):?>
<?php echo $i."\n";?>
<?php endif;?>
<?php endfor;?>
|
view (5 lines, 6 lines of output) |
/*如果一个数组只允许读,而不允许写的时候定义的时候用const关键字*/
#include <stdio.h>
#define MONTHS 12
int main(void){
|
view (13 lines, 12 lines of output) |
#include <stdio.h>
#include <string.h>
#define NAME "GIGATHINK, INC. "
#define ADDRESS "101 Megabuck Plaza"
#define PLACE "Megapolis,CA 94904"
|
view (32 lines, 5 lines of output) |
#include <stdio.h>
#include <string.h>
#define NAME "GIGATHINK, INC. "
#define ADDRESS "101 Megabuck Plaza"
#define PLACE "Megapolis,CA 94904"
|
view (27 lines, 3 lines of output) |
#include <stdio.h>
#define NAME "XINGYUAN WANG"
#define ADDRESS "SHANXI XIAN"
#define JOB "PHPER"
|
view (26 lines, 5 lines of output) |
//大家知道的++和--
/*如果一个变量出现在一个函数的多个参数中,不要将++或者--放在参数上面
当一个变量多次出现在一个表达式里面,不要将++或者--放在变量上面如果
y=n++ + n++
*/
|
view (15 lines, 15 lines of output) |
//我知道的除法
#include <stdio.h>
int main(void){
printf("5/4 is %d\n",5/4);
printf("6/3 is %d\n",6/3);
|
view (11 lines, 6 lines of output) |
//printf函数的格式控制说明
#include <stdio.h>
#define PI 3.141593
int main(void){
int number=5;
|
view (14 lines, 4 lines of output) |
//八进制十六进制和十进制分别输出100,要以8,16,2进制表示前面要加#号
/*十进制转换为2,8,16进制的时候分别除以2,8,16然后余数从低到高排列即可*/
#include <stdio.h>
int main(void){
|
view (14 lines, 2 lines of output) |
//函数调用函数的使用范例
#include <stdio.h>
void one_three(void);/*会调用one和two函数*/
void two(void);/*输出two*/
|
view (28 lines, 5 lines of output) |
//编写一个程序输出你的姓名和地址
#include <stdio.h>
int main(void){
printf("sdeep wang\n");
printf("陕西西安高新区\n");
|
view (7 lines, 2 lines of output) |
//c语言课后习题练习printf 和\n换行的练习
#include <stdio.h>
int main(void){
printf("wang xingyuan\n");
|
view (10 lines, 4 lines of output) |
lines='242080 三重県 名張市 242161 三重県 伊賀市
244724 三重県 南伊勢町 242039 三重県 伊勢市
244724 三重県 南伊勢町 244708 三重県 度会町
244724 三重県 南伊勢町 244716 三重県 大紀町
244724 三重県 南伊勢町 242152 三重県 志摩市
|
view (17 lines, 6 lines of output) |
lineStr = '36.45.163.126 - oadev [25/Apr/2014:18:23:29 +0900] "GET /categ=0/login_id=140434/blog/ HTTP/1.1" 200 0 66242'
(@ip, @test, @test2, @time, @timelag, @method, @file) = lineStr.split(nil)
|
view (12 lines, 3 lines of output) |
class Person
#用这行代码替换上面的那9行代码
attr_reader :name, :age, :motherland
#用这行代码替换类变量的设置值
attr_writer :name, :age, :motherland
|
view (28 lines, 4 lines of output) |
class MegaGreeter
attr_accessor :names
# Create the object
def initialize(names = "World")
|
view (58 lines, 12 lines of output) |