Skip to content

Instantly share code, notes, and snippets.

@Yi-Tseng
Yi-Tseng / 範例程式.c
Created September 4, 2012 15:40
if/else 範例
// 可以只寫單一if
if(條件){
運算式
}
// 也可以省略大括號,但是只會執行一行
if(條件)
運算式;
// 也可以寫if / else
int a = 1;
printf("%d\n",a++);
int b = 1;
printf("%d\n",++b);
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main(int argc, const char * argv[])
{
int r,c;
char* a = "vs lbh pna frr guvf zrffntr, jrypbzr gb wbva gghpfp!";
for(r=1;r<26;r++){
for(c=0;c<strlen(a);c++){
if(isalpha(a[c])){
@Yi-Tseng
Yi-Tseng / test.py
Created September 21, 2012 16:43
using gpio to control raspberry PI I/O
from time import sleep
import RPi.GPIO as GPIO
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BOARD)
GPIO.setup(13, GPIO.OUT)
GPIO.setup(15, GPIO.OUT)
GPIO.setup(16, GPIO.OUT)
GPIO.output(13,False)
GPIO.output(15,False)
GPIO.output(16,False)
#include<stdio.h>
#include <string.h>
#include<stdlib.h>
#include <sys/stat.h>
int main(){
FILE* file_a;
FILE* file_b;
FILE* file_c;
char buffer[1024];
@Yi-Tseng
Yi-Tseng / foo.c
Created September 22, 2012 16:46
#include<stdio.h>
#define M 5
#define N 6
int max(a,b){
return a>=b?a:b;
}
int main(){
int x[M] = { 1, 1, 2, 3, 2 };
int y[N] = { 2, 2, 4, 3, 1, 2 };
int c[M][N];
from threading import Thread
import RPi.GPIO as GPIO
x = 0
def keyListen():
stat = False
global x
while 1:
if GPIO.input(11) and not stat:
stat = True
#include <stdio.h>
#define swap(x,y) int t=x;x=y;y=t;
typedef unsigned long long ull;
ull foo(int a,int b){
ull cycle;
ull c,n;
ull max = 0;
if(a>b){
swap(a,b)
}
#include <stdio.h>
#include <string.h>
int main(int argc, const char * argv[])
{
char num[1010] = {0};
while(scanf("%s",num)!=EOF){
if(strcmp(num, "0") == 0){
break;
}
#include <stdio.h>
#include <ctype.h>
struct node{
int cn;
char c;
};
typedef struct node Node;
int main(int argc, const char * argv[])
{
Node cc[26];