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

1A,700多MS,贴个代码

Posted by cxlm at 2018-01-29 09:35:24 on Problem 1750
#include<iostream>
#include<cstring>
using namespace std;

/*空格数列表*/
char sp[][12]={""," ","  ","   ","    ","     ","      ","       ","        ","         ","          "};
int cou=0;
char *spa(char *p1,char *p2){
    int i;

    for(i=0;p1[i]!='\0';i++){
        if(p1[i]==p2[i]){
            if(i>cou){
                return sp[++cou];
            }else{
                continue;
            }
        }else{
            cou=i;
            return sp[cou];
        }
    }
    cou=i;
    return sp[cou];
}

int main(){
    char dic[15],nex[15];

    cin>>dic;
    cout<<dic<<endl;//直接输出第一个字符串

    while(scanf("%s",&nex)!= EOF){
        printf("%s%s\n",spa(dic,nex),nex);
        strcpy(dic,nex);
    }

    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