2008年4月7日星期一

Applications of Modulus computing 1

==== 20071028 21:11 发布于 redspid.blog.163.com ====
1
# include <iostream>
2 # include <string>
3 using namespace std;
4
5 int main() {
6 const int line_size = 4;
7 int counter = 1;
8 string array[] = {"compiler", "C++", "Perl", "GNU", "Linux",
"free", "OpenSource", "software", "Debian",
"hurd", "kernel"};
9
10 int out_time = sizeof(array) / sizeof(array[0]);
11
12 for (int i=0; i<out_time; i++) {
13 // 输出一个字符串后判断当前行是否输出了 line_size 个字符串
14 // 否,则输出一个空格;是,则换行
15 cout<<array[i]<<(counter % line_size ? ' ' : '\n');
16 counter++;
17 }
18
19 return 0;
20 }
o(∩_∩)o...  看看上面用 vim 生成的语法高亮代码,怎一个酷字了得!

没有评论: