注册 登录
编程论坛 C++教室

一个错误找不出来……【关于字符处理的】提示RE,无法通过啊!!!!

love24114 发布于 2012-01-20 18:20, 701 次点击
http://
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

void PRINTNUM(string a)
{
    int j;
    for (j=0;j<7;j++)
    {   
        cout<<a[j];
        if (j==2)
            cout<<"-";
    }   
}
int main()
{
    int n,i,j,cnt;
    int c2num[25]={2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7,7,7,7,8,8,8,9,9,9};
    string istr[1000];
    string phonum[1000];
    cin>>n;
    for (i=0;i<n;i++)
        cin>>istr[i];
    for (i=0;i<n;i++)
    {
        cnt=0;
        for (j=0;j<istr[i].size();j++)
        {
            if (isupper(istr[i][j]) &&istr[i][j]!='Z')
            {
                phonum[i]+=c2num[istr[i][j]-'A']+'0';
            }
            if (isdigit(istr[i][j]))
            {
                phonum[i]+=istr[i][j];
            }
        }
    }
    sort(phonum,phonum+n);
    for (i=0;i<n;i++)
    {
        int cnt=0;
        j=i;
        while(phonum[j] == phonum[j+1])
        {
            cnt++;
            j++;
        }
        if (cnt)
        {
            PRINTNUM(phonum[i]);
            cout<<" "<<cnt+1<<endl;
                i+=cnt;
        }
    }
    return 0;
}

[ 本帖最后由 love24114 于 2012-1-22 10:37 编辑 ]
7 回复
#2
apull2012-01-20 19:20
12
4873279
ITS-EASY
888-4567
3-10-10-10
888-GLOP
TUT-GLOP
967-11-11
310-GINO
F101010
888-1200
-4-8-7-3-2-7-9-
487-3279
310-1010 2
487-3279 4
888-4567 3


运行正常啊。。
bcc编译。
#3
cqpreson2012-01-20 21:22
Output size is 936.61 KB
Process terminated with status 0 (0 minutes, 1 seconds)
0 errors, 0 warnings。
正常啊。
#4
孤独的根号32012-01-21 01:43
这程序要实现什么功能?
#5
bardon_20092012-01-21 10:18
编译成功。
#6
BianChengNan2012-01-21 10:46
以下是引用孤独的根号3在2012-1-21 01:43:13的发言:

这程序要实现什么功能?
根号三??
#7
love241142012-01-22 10:35
无法通过啊,这是关键啊
#8
bardon_20092012-01-28 09:57
我是用visual studio 2010 编译通过的,没改动一下。
1