紹介マニアMoinMoin

wcの機能実装。

Java

import java.io.*;
public class LineCount {
    public static void main(String args[]) {
        try {
            BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
            String str;
            int line = 0;
            while ((str = in.readLine()) != null) {
                line += 1;
            }
            System.out.println(line);
            in.close();
        }
        catch (IOException e) {
            e.printStackTrace();
        }
    }
}

Python

Emacs Lisp

Scheme


SoftwareTools CategoryPrograming CategoryEmacs CategoryPython CategoryJava

紹介マニアMoinMoin: SoftwareTools/行数を数える (last edited 2002-10-26 15:00:00 by )