C++问题~1

来源:百度知道 编辑:UC知道 时间:2024/05/05 05:34:24
1. Write a program that reads from the keyboard a line of text and
then computes and displays the number of upper case letter, lower
case letters and digits in the line. Make and use your own functions
isupper, islower, and isdigit.

//1. Write a program that reads from the keyboard a line of text and
  //then computes and displays the number of upper case letter, lower
  //case letters and digits in the line. Make and use your own functions
  //isupper, islower, and isdigsit.

  #include<iostream>
  #include<string>
  using namespace std;

  bool isupper(char c)
  {
  if('A'<=c&&c<='Z')
  return true;
  return false;
  }

  bool islower(char c)
  {
  if('a'<=c&&c<='z')
  return true;
  return false;
  }

  bool isdigsit(char c)
  {
  if('0'<=c&&c<='9')
  return true;
  return false;
  }

  void main()
  {
  string str;
  cout<<"Enter the text:";
  cin>>str;
  cout<<endl;

  int num=0;
  int low=0;
  int upp=0;