OJ刷题---Excel地址转换

来源:互联网 发布:程序员面试金典百度云 编辑:程序博客网 时间:2024/06/05 11:50

  题目要求:



输入代码:

<pre name="code" class="cpp">#include<iostream>#include<cstdio>using namespace std;int main(){    int i,j,n,p,q;    char str1[10];    char str2[10];    while(cin>>n&&n)    {        while(n--)        {            gets(str1);            for(i=0; ; i++)            {                if(str1[i]=='C')//验证输入格式                    break;                cin>>str1[1]>>p>>str1[i+1]>>q;            }            j=0;            while(q)            {                if(q%26==0)                {                    str2[j++]='Z';                    q=q/26-1;                }                else                {                    str2[j++]=q%26+'A'-1;                    q=q/26;                }            }            for(i=j-1; i>=0; i--)            {                cout<<str2[i];            }            cout<<p<<endl;        }    }    return 0;}


运行结果:


总结:

忧伤的输入格式。。。无语!不知道怎样改进才好,求大神指点


0 0
原创粉丝点击