毛のはえたようなもの

インターネット的なものをつらつらとかきつらねる。

2007-10-07から1日間の記事一覧

相異なる文の種類の数(Pythonの場合)

#! /user/local/bin/python import string num = [] chohuku =0 for line in open ('../data_c.txt','r'): if line == 0: break else: num.append(line) num.sort(lambda x, y: cmp(string.lower(x), string.lower(y))) for i in range(len(num)-1): if num[…

相異なる文の種類の数(c++の場合)

#include <string> #include <iostream> #include <vector> #include <algorithm> using namespace std; int main(void){ vector<string> line; string oneString; while(getline(cin,oneString) ){ if(oneString == "") break; line.push_back(oneString); } sort(line.begin(), line.end(),greater<string>()); i</string></string></algorithm></vector></iostream></string>…

相異なる文の種類の数(c言語の場合)

#include <stdio.h> #include <math.h> #include <string.h> int cmp(const char *a,const char *b){ return strcmp(b,a); } int main(void){ char buf[1000]; FILE *stream; char string[10001][70]; int i = 0; int j = 0; int chohuku =0; while(fgets(buf, 1000,stdin) != NULL){ st</string.h></math.h></stdio.h>…

相異なる文の種類の数(Rubyの場合)

ary = Array.new File.open("../data_c.txt","r"){|f| f.each{|line| line.chomp! !="" && ary << line } } p (ary|ary).size Rubyみじかっ

C/C++/Python/Ruby比較6

文字列を読み込み、相異なる文の種類の数を表示する。具体的には以下のデータで7と表示されればよい。 Is this the first line? Yes, it is. This is the second. I think that was the third. Is this the first line? No, it is not. But this is not the…