回 帖 发 新 帖 刷新版面

主题:[讨论]谁能帮我找错?

#include<iostream.h>
void main()
{
    char ch;
    int nother(0),ndigit[10];
    for(int i=0;i<10;i++)
        ndigit[i]=0;
    cout<<"Input some characters:\n";
    cin>>ch;
    while(ch!='#')
    {
        switch(ch)
        {
        case'0':
        case'1':
        case'2':
        case'3':
        case'4':
        case'5':
        case'6':
        case'7':
        case'8':
        case'9':++ndigit[ch-'0'];
                break;
        default:++nother;
        }
        cin>>ch;
    }
    cout<<"digit=";
    for(i=0;i<10;i++)
        cout<<ndigit[i]<<'';
    cout<<"\nother="<<nother<<endl:
}
编译结果在附件的图中

回复列表 (共2个回复)

沙发

你都没有说清楚你想做什么???

板凳


结果运行不出来

我来回复

您尚未登录,请登录后再回复。点此登录或注册