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 |
帮忙测试下!我一直在第6个wr#include <stdio.h> #include<iostream.h> int main() { char a[150]={0},c; int b[150]={0}; int i,j,n=0,m=0,k,r,t; for(i=0;a[i]!='\0';i++) n++; k=1; while(1) { c=getchar(); if(c==10)break; a[i]=c,i++; } for(i=0;a[i]!='\0';i++) n++; k=1; for(i=0;i<=n;i++) { if(a[i]==' ')b[i]=1; } while(k<=n) { for(t=0;t<n;t++) { for(i=0,j=k+i;i<=n;) { while(b[i]!=0)i++; j=i+k; while(b[j]!=0)j++; if(a[i]=='('&&a[j]==')') { b[i]=1; b[j]=1; if(k>=2) { for(r=i+1;r<j;r++) if(b[r]!=1)b[r]=2; } i++; j++; } else if(a[i]=='['&&a[j]==']') { b[i]=1; b[j]=1; if(k>=2) { for(r=i+1;r<j;r++) { if(b[r]!=1)b[r]=2; } } i++; j++; } else i++; } } k++; } for(i=0;a[i]!='\0';i++) { if(b[i]==1)printf("%c",a[i]); if(b[i]!=1) { if(a[i]=='(')printf("()"); if(a[i]==')')printf("()"); if(a[i]=='[')printf("[]"); if(a[i]==']')printf("[]"); m++; } } cout<<m; if(a[i]==0)cout<<' '; return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator