| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
Re:为什么run time error 啊?求救!!大虾帮忙!!In Reply To:Re:为什么run time error 啊?求救!!大虾帮忙!! Posted by:cpp050300448135 at 2005-05-11 02:27:27 这是第一个最短得程序,但是效率不高,因为其中用了二重循环……而且比如,1995那个数据,我是硬循环出来得……显然不行……
#include<iostream>
#include<string>
using namespace std;
string reset(int *array, string str, int num)
{
string result;
result.resize(num, ' ');
str.resize(num, ' ');
for(int i=0; i<num; i++)
result[array[i]-1]=str[i];
return result;
}
void main()
{
int * array, num, k;
string str;
while(1)
{
cin>>num;
if(num==0) break;
array=new int[num];
for(int i=0; i<num; i++)
cin>>array[i];
for(;;)
{
cin>>k;
if(k==0) break;
cin.ignore(1,'\n');
getline(cin, str);
for(i=0; i<k; i++)
str=reset(array, str, num);
cout<<str;
}
if(k==0) cin>>num;
if(num==0) break;
}
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator