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

Re:我是新手,请帮忙看看代码,是不是因为循环太多超时的?谢谢!

Posted by suniteboy at 2008-10-28 12:45:30 on Problem 2681
In Reply To:我是新手,请帮忙看看代码,是不是因为循环太多超时的?谢谢! Posted by:ccnuteam4 at 2008-08-21 18:05:27
我也是刚开始学的,看看我的AC来的
#include <iostream>
#include <string.h>
using namespace std;
int main()
{	int n;
	char a[50];
	char b[50];
	int al,bl;
	int i,j;
	int k=0;
	int count;
	cin>>n;
	char c[10]; 
	gets(c); 
	while(n-->0)
	{k++;
	gets(a);
	gets(b);
	al=strlen(a);
	bl=strlen(b);
		for(i=0,count=0;i<bl;i++)
		for(j=0;j<al;j++)
			if(b[i]==a[j]) {a[j]='0';count++;break;}	
		cout<<"Case #"<<k<<":  "<<al+bl-2*count<<endl;
	}
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