Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

这个程序怎么错了?

Posted by mengzhu929 at 2007-04-23 18:48:31 on Problem 2945
#include <iostream>
#include <string>
#include <algorithm>
#include <map>

using namespace std;
int n; int m;
int get_hash_value(char* p)
{
	int a = 0;
	for(int k = 0; k < m; k++)
	{
		switch(p[k])
		{
			case 'A': a = a+2*(20-k); break;
			case 'C': a = a+3*(20-k); break;
			case 'G': a = a+4*(20-k); break;
			case 'T': a = a+5*(20-k); break;
		}
		//a += (p[k]-'A')*(k+1);
	}
	return a;
}

int ELFhash(char *key)
{
	unsigned long h=0;
	while(*key)
	{
		h=(h<<4)+*key++;
		unsigned long g=h&0Xf0000000L;
		if(g)
			h^=g>>24;
		h&=~g;
	}
	return h%54117;
}	


map<string, int> string_count;
int copy_count[20001];

int main(int argc, char* argv[])
{
	while(cin >> n >> m)
	{
		memset(copy_count, 0, sizeof(copy_count));
		if(n == 0) break;
		for(int i = 0; i < n; i++)
		{
			char str[20];
			scanf("%s", str);
		//	int value = get_hash_value(str);
			map<string, int>::iterator iter;
			if((iter = string_count.find(str)) != string_count.end())
			{
				iter->second++;
			}
			else
			{
				string_count.insert(make_pair(str, 1));
			}
		}
		for(map<string, int>::iterator iter = string_count.begin(); iter != string_count.end(); iter++)
		{
			copy_count[iter->second]++;
		}
		for(int k = 1; k <= n; k++)
		{
			printf("%d\n", copy_count[k]);
		}
	}
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator