找回密码
 入驻
搜索
查看: 402|回复: 8

求助-----以下程序错在哪?

[复制链接]
发表于 2008-5-30 10:44:43 | 显示全部楼层 |阅读模式
题目;编一函数,统计字符串的个数,并分别统计字母及数字的个数.
#include<iostream.h>
char *str;
void a()
{
    int x=0,y=0,z=0;
    while(*str++!='\0')
    {
       x++;
       if('a'<=*str&&*str<='z'||'A'<=*str&&*str<='Z')
       y++;
       if(0<=*str&&*str<=9)
       z++;
    }
    cout<<"x="<<x<<endl;
    cout<<"y="<<y<<endl;
    cout<<"z="<<z<<endl;
}
void main()
{
   cin>>*str;
   a(*str);
}
发表于 2008-5-30 10:45:37 | 显示全部楼层
C++的不知道
回复

使用道具 举报

 楼主| 发表于 2008-5-30 10:48:39 | 显示全部楼层
如何解决以上错误的程序,请各高手帮帮忙。
回复

使用道具 举报

发表于 2008-5-30 10:51:38 | 显示全部楼层
没学过,~~~~~~~~
回复

使用道具 举报

发表于 2008-5-30 15:27:46 | 显示全部楼层
没学C++
回复

使用道具 举报

发表于 2008-5-30 15:32:28 | 显示全部楼层
#include<iostream.h>
void a(char *str)
{
    int x=0,y=0,z=0;
    while(*str++!='\0')
    {
       x++;
       if('a'<=*str&&*str<='z'||'A'<=*str&&*str<='Z')
       y++;
       if(0<=*str&&*str<=9)
       z++;
    }
    cout<<"x="<<x<<endl;
    cout<<"y="<<y<<endl;
    cout<<"z="<<z<<endl;
}
void main()
{
   char *s
   cin>>*s;
   a(*s);
}

你看这样行不行
回复

使用道具 举报

发表于 2008-5-30 16:17:55 | 显示全部楼层
问题已经帮你解决了
#include<iostream.h>
char *str;
void a()
{
    int x=0,y=0,z=0;
    while(*str!='\0')
    {
       x++;
       if('a'<=*str&&*str<='z'||'A'<=*str&&*str<='Z')
       y++;
       if('0'<=*str&&*str<='9')
       z++;
       *str++;
    }
    cout<<"x="<<x<<endl;
    cout<<"y="<<y<<endl;
    cout<<"z="<<z<<endl;
}
void main()
{
   cin>>str;
   a();
}
回复

使用道具 举报

 楼主| 发表于 2008-5-30 17:56:46 | 显示全部楼层

回复 6# 的帖子

谢了,但是还是运行不了耶.
回复

使用道具 举报

 楼主| 发表于 2008-5-30 17:59:08 | 显示全部楼层

回复 7# 的帖子

谢了,这个程序可以运行了.
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 入驻

本版积分规则

QQ|Archiver|手机版|小黑屋|思明论坛

GMT+8, 2024-6-10 01:12 , Processed in 0.067591 second(s), 16 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表