Skip to content

Instantly share code, notes, and snippets.

@tomcha
tomcha / person.rb
Created March 7, 2015 04:13
ハッシュを使う練習問題解答例
person = {
'name' => '@tomcha_',
'hobby' => 'programming',
'food' => '衣笠丼'
}
puts person['name']
puts person['hobby']
puts person['food']
@tomcha
tomcha / yourname.rb
Created March 7, 2015 04:16
入力、出力、変数を使う練習問題解答例
print "あなたの名前は? >>>"
name = gets
name.chomp!
puts "あなたは#{name}さんですね。"
@tomcha
tomcha / 1-17.c
Created March 17, 2015 10:45
1-17
#include <stdio.h>
#define MAXLINE 1000
int main(){
int c;
int i,j;
char line[MAXLINE];
i = 0;
while((c = getchar()) != EOF){
line[i] = c;
@tomcha
tomcha / 1-18.c
Created March 17, 2015 10:46
1-18
#include <stdio.h>
#define MAXCHAR 100
void delblank(char line[], char newline[]);
void cleararray(char array[]);
int main(){
int c;
int i;
char line[MAXCHAR];
@tomcha
tomcha / 1-19.c
Created March 17, 2015 10:48
1-19
#include <stdio.h>
#define MAXCHAR 100
void reversd(int i, char s[], char r[]);
void cleararray(char array[]);
int main(){
char s[MAXCHAR];
char r[MAXCHAR];
int c;
@tomcha
tomcha / 1-20.c
Created March 17, 2015 10:50
1-20
#include <stdio.h>
#define MAXCHAR 100
#define TABSTOP 5
int detab(char strings[], int clocate, int n);
void cleararray(char array[]);
int main(){
char strings[MAXCHAR];
int c;
@tomcha
tomcha / 1-21.c
Created April 3, 2015 10:42
1-21
#include <stdio.h>
#define MAXCHAR 100
#define TABSTOP 6
void entab();
int main(){
int c;
char str[MAXCHAR];
int i, j;
@tomcha
tomcha / 1-22.c
Created April 5, 2015 12:12
1-22
#include <stdio.h>
#define N 10
#define MAXSTRINGS 100
int ggetline(char str[]);
void cleararray(char str[], int n);
int main(){
char str[MAXSTRINGS];
char newstr[MAXSTRINGS];
@tomcha
tomcha / 1-23.c
Last active August 29, 2015 14:18
1-23
#include <stdio.h>
#define MAXSTRINGS 1000
//
//ファイル操作はまだ学習してないので、Cのソースをcatとパイプで受け取る前提
int main(){
int c;
int i = 0;
int j;
int qflg; // '-> 1, "-> 2
int eflg; // normal ->0, // -> 1, /* -> 2
@tomcha
tomcha / 1-24.c
Created April 7, 2015 10:27
1-24
#include <stdio.h>
#define MAXSTRINGS 10000
// 1-23に同じく、catとパイプでソースを受け取る
int main(){
int c;
char str[MAXSTRINGS];
int i = 0, j;
int n = 1;
int qflg =0; // normal -> 0, sq -> 1, dq -> 2
int eflg = 0; // normal -> 0, // -> 1, /* -> 2