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 bwsolar at 2008-11-04 20:12:27 on Problem 1617
#include<iostream>
#include<stdio.h>
#include<string>
using namespace std;
struct point{
	char first;
	int second;
};
int main(){
	string end;
	point queue[11],product;
	int j,k,n,l;
	bool flag;
	cin>>end;
	if(end!="THEEND"){
	n=end.size();
	for(int i=0;i<n;i++){
		queue[i].first=end[i];
		queue[i].second=i;
	}
	flag=true;
	}
	else flag=false;
	while(flag){
		string second1,first1;
		int count1,count=0;
		for(int ii=0;ii<n-1;ii++){
			k=ii;
			for(j=ii+1;j<n;j++){
				if(queue[j].first<queue[k].first){
					k=j;
				}
			}
			if(k!=ii){
				product.first=queue[ii].first;
		        product.second=queue[ii].second;
		        queue[ii].first=queue[k].first;
		        queue[ii].second=queue[k].second;
		        queue[k].first=product.first;
		        queue[k].second=product.second;	
			}
		}
		cin>>second1;
        l=second1.size();
		first1=second1;
		count1=l/n;
		for(int c=0;c<n;c++){
			int w=queue[c].second;
			for(j=0;j<count1;j++)
				first1[n*j+w]=second1[count++];
			}
		cout<<first1<<endl;
		cin>>end;
		if(end!="THEEND"){
			n=end.size();
			for(int iii=0;iii<n;iii++){
				queue[iii].first=end[iii];
		        queue[iii].second=iii;
			}
			flag=true;
		}
		else flag=false;
	}
	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