| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 558 人关注过本帖
标题:有人会么
只看楼主 加入收藏
hangtian
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2008-3-26
收藏
 问题点数:0 回复次数:3 
有人会么
(1)如果C是大写字母,则输出相对应的小写字母;
  (2)如果C是小写字母,则输出相对应的大写字母;
  (3)如果C是数字0~9,则输出其对应的ASCII码值(16进制);
  (4)如果C是除以上情况之外的值,则输出“Control  key”
输出格式:
The source key is: **,after converting is: ##.
2008-04-01 21:02
hgchenkv
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2008-3-14
收藏
得分:0 
给你个程序,运用这个算法根据ASCII表if&else if&else下就可以了,
/*
a转换为A
b转换为B
*/

#include<iostream.h>
class Sample
{
    char c1,c2;
public:
    Sample(char a){c2=(c1=a)-32;}
    void disp()
    {
        cout<<c1<<"转换为"<<c2<<endl;
    }
};

void main()
{
    Sample a('a'),b('b');
    a.disp();
    b.disp();
}
2008-04-02 09:49
newyj
Rank: 2
等 级:新手上路
威 望:3
帖 子:542
专家分:0
注 册:2008-1-4
收藏
得分:0 
#include<iostream>
#include<cctype>
using namespace std;

int main(){
  char str='0';
  cin>>str;
  if(isupper(str))
    cout<<"The source key is: "<<str<<",after converting is: "<<static_cast<char>(tolower(str))<<endl;
  else if(islower(str))
    cout<<"The source key is: "<<str<<",after converting is: "<<static_cast<char>(toupper(str))<<endl;
  else if(isdigit(str))
    cout<<"The source key is: "<<str<<",after converting is: "<<hex<<str<<endl;
  else
    cout<<"Control  key";
  system("pause");
  return 0;         
}
输出toupper(str)时为什么是int型的
还必须得强制转换啊
2008-04-02 13:21
张信哲
Rank: 1
等 级:新手上路
帖 子:139
专家分:0
注 册:2008-4-3
收藏
得分:0 
hangtian   真可爱
2008-04-13 21:42
快速回复:有人会么
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.020333 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved