This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
============================================================================ | |
Name : test_lf_cr.c | |
Author : shaobin0604 | |
Version : | |
Copyright : Your copyright notice | |
Description : This small piece of code is used to detect the new line character | |
on different platforms. | |
eg. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# | |
# This script will generate a progress bar in console interface | |
# | |
0.upto(50) do |i| | |
printf("progress: [%-50s] %d%%\r", '#' * i, i * 2); | |
sleep(1) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#-------------------------------------------------- | |
# Name: fullmetal_alchemist_comic_book_download_script.rb | |
# Description: This Ruby script is used to batch download Fullmetal Alchemis | |
# comic books which are hosted on http://www.jumpcn.com. | |
# Make ensure wget program can be found via PATH environment variable. | |
# The Windows version of wget program can be found at http://users.ugent.be/~bpuype/wget/. | |
# | |
# Usage: | |
# ruby fullmetal_alchemist_comic_book_download_script.rb chapter | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# == Question: | |
# 12 people stand in two rows, 6 per row. People in each row must be | |
# arranged by their height and person in the second row must be taller | |
# than the one up front. Well, how many kinds of arrangement can be? | |
# | |
# == Solution: | |
# Suppose that person1 to person12 are marked by their height ascent | |
# We find the following rules: | |
# 1. Person at the first position of row 1 must be person1 | |
# 2. Person at the second positon of row 1 must be in person2...person3, and person |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#define IN 1 /* inside a word */ | |
#define OUT 0 /* outside a word */ | |
int main(void) | |
{ | |
int c, nl, nc, nw, state; | |
nl = nc = nw = 0; | |
state = OUT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Exercise 1-19. Write a function reverse(s) that reverses the character | |
* string s. Use it to write a program that reverses its input a line at a time. | |
* | |
*/ | |
#include <stdio.h> | |
#define MAXLINE 1000 | |
void reverse(char line[]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Exercise 1-20. Write a program detab that replaces tabs in the input | |
* with the proper number of blanks to space to the next tab stop. Assume | |
* a fixed set of tab stops, say every n columns. Should n be a variable | |
* or a symbolic parameter? | |
*/ | |
#include <stdio.h> | |
#define MAXLEN 1000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Exercise 1-21. Write a program entab that replaces strings of blanks by the minimum | |
* number of tabs and blanks to achieve the same spacing. Use the same tab stops as for detab. | |
* When either a tab or a single blank would suffice to reach a tab stop, which should be given | |
* preference? | |
*/ | |
#include <stdio.h> | |
#define TABINC 8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\a alert (bell) character | |
\b backspace | |
\f formfeed | |
\n newline | |
\r carriage return | |
\t horizontal tab | |
\v vertical tab | |
\\ backslash | |
\? question mark | |
\' single quote |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Exercise 2-3. Write a function htoi(s), which converts a string of hexadecimal | |
* digits (including an optional 0x or 0X) into its equivalent integer value. The | |
* allowable digits are 0 through 9, a through f, and A through F. | |
*/ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#define BASE 16 | |
#define TRUE 1 | |
#define FALSE 0 |
OlderNewer