// $Id: wc.csharp,v 1.0 2002/02/14 10:21:00 dada Exp $ // http://dada.perl.it/shootout/ using System; class App { public static int Main(String[] args) { int nread; int i; char c; char[] buf = new char[4096]; int nl = 0, nw = 0, nc = 0; bool state = false; while( (nread = Console.In.Read( buf, 0, 4096)) > 0 ) { nc += nread; for (i=0; i<nread; i++) { c = buf[i]; if (c == '\n') ++nl; if (c == ' ' || c == '\n' || c == '\t') state = false; else if (state == false) { state = true; nw++; } } } Console.WriteLine(nl.ToString() + " " + nw.ToString() + " " + nc.ToString() + "\n"); return(0); } }