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 tide713 at 2004-11-21 19:43:40 on Problem 2013
我的程序不知道错误在那里。希望你们能看看。着急呀!
#include<iostream.h>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
void main()
{   int a,i,k;
    char *b[15],*str;
	k=0;
	while(1)
	{   cin>>a;//输入整数
	    if(a==0)//while循环结束标志
			break;
		k++;
		for(i=0;i<a;i++)
		{
		str=(char *)malloc(sizeof(char)*26);
        cin>>str;
		b[i]=str;
        }
		if(a==1)//当输入一个字符串
		{	cout<<"SET "<<k<<endl;
		    cout<<b[i]<<endl;
			continue;
		}
		
		if(a%2==0)//当输入偶数个字符串
		{   cout<<"SET "<<k<<endl;
		   
			for(i=0;i<a;i+=2)//从第一个开始输出,输出的是第1 3 5 7 9等等
			{  
                cout<<b[i]<<endl;
			}
			for(i=a-1;i>=0;i-=2)//反向输出,输出的是偶数位的字符串
			{   
				cout<<b[i]<<endl;
			}
			continue;
		}
		if(a%2==1&&a!=1)//当输入奇数个字符串
		{   cout<<"SET "<<k<<endl;
		    
            for(i=0;i<a;i+=2)//从第一个开始输出,输出的是第1 3 5 7 9等等
			{  
                cout<<b[i]<<endl;
			}
			for(i=a-2;i>=0;i-=2)//反向输出,输出的是偶数位的字符串
			{   
				cout<<b[i]<<endl;
			} 
			continue;
		}
	}
}

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