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

为什么第二组数据K会多一个呢?

Posted by haha___wokao at 2013-10-27 12:04:53 on Problem 1298
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
void deal(char *s)
{
    char k[105];
    for(int i=0;i<strlen(s);i++)
    {

         if('F'<=s[i]&&s[i]<='Z')
         k[i]=(char)(s[i]-5);
         else if('A'<=s[i]&&s[i]<='E')
         k[i]=(char)(s[i]+21);
         else
            k[i]=(char)s[i];
    }
    getchar();
    for(int i=0;i<strlen(s);i++)//这三行
        cout<<k[i];            //是
    cout<<endl;                //AC的
    //cout<<k<<endl;          //换这个会错
}
int main()
{
    char s1[105],s2[105],s3[105];
    while(1)
    {
        memset(s1,0,105);
        memset(s2,0,105);
        memset(s3,0,105);
        scanf("%s",s1);
        if(!strcmp(s1,"ENDOFINPUT"))
            break;
        getchar();
        gets(s2);
        scanf("%s",s3);
        deal(s2);
    }
    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