阳光灼热,数不尽夏日繁华;蝉鸣幽幽,道不完苦辣酸甜。 收藏本站
登陆 / 注册 搜索

阅读:8.9K   回复: 7

新人第一次发帖问个很傻的问题

[复制链接]
三星半月 「初入古黑」 2016-9-16 01:37 来自手机 |显示全部楼层

这个用户很懒,还没有填写自我介绍呢~

一个短整数是二个字节,一个字母是一个字节,但是字母是由阿克斯代码转化为整数,比如说A是065,再向计算机里面存储,但是转化为整数为什么却比整数字节少,不应该也是二字节,,,,,在自学c语言,没有人教导,如果问了很愚蠢的问题抱歉了
上一篇
下一篇
帖子热度 9005 ℃

小执念 古黑浩劫论坛大牛 2016-9-16 10:24 |显示全部楼层

可遇不可求的事:故乡的云,上古的玉,随手的诗,十九岁的你。

管理员

  1.发错板块,下不为例。

  2.C语言中规定char类型占一个字节,short类型占两个字节。如你所说A的ascii为65,那1的ascii为49,他们最后都是以ascii方式存储的。

  最后给上 int、long、double、char表示范围(最大最小值)
👊⛄🍼🆘🐝‏
新人第一次发帖问个很傻的问题 QQ截图20160916101307.png

全屏查看
  1. #include<iostream>  
  2. #include<string>  
  3. #include <limits>  👨🦱‌💍✏🥰🤟
  4. using namespace std;  
  5.   
  6. int main()  
  7. {  
  8.     cout << "type: \t\t" << "************size**************"<< endl;  👵‍🧻💀🙌
  9.     cout << "bool: \t\t" << "所占字节数:" << sizeof(bool);  
  10.     cout << "\t最大值:" << (numeric_limits<bool>::max)();  
  11.     cout << "\t\t最小值:" << (numeric_limits<bool>::min)() << endl;  
  12.     cout << "char: \t\t" << "所占字节数:" << sizeof(char);  
  13.     cout << "\t最大值:" << (numeric_limits<char>::max)();  🧑‍🌾‌👙💶😋👊
  14.     cout << "\t\t最小值:" << (numeric_limits<char>::min)() << endl;  
  15.     cout << "signed char: \t" << "所占字节数:" << sizeof(signed char);  
  16.     cout << "\t最大值:" << (numeric_limits<signed char>::max)();  
  17.     cout << "\t\t最小值:" << (numeric_limits<signed char>::min)() << endl;  
  18.     cout << "unsigned char: \t" << "所占字节数:" << sizeof(unsigned char);  
    👎🏦♏🦚‌
  19.     cout << "\t最大值:" << (numeric_limits<unsigned char>::max)();  
  20.     cout << "\t\t最小值:" << (numeric_limits<unsigned char>::min)() << endl;  
  21.     cout << "wchar_t: \t" << "所占字节数:" << sizeof(wchar_t);  
  22.     cout << "\t最大值:" << (numeric_limits<wchar_t>::max)();  
  23.     cout << "\t\t最小值:" << (numeric_limits<wchar_t>::min)() << endl;  👨‍🚒‎🩴🔌🤔👃
  24.     cout << "short: \t\t" << "所占字节数:" << sizeof(short);  
  25.     cout << "\t最大值:" << (numeric_limits<short>::max)();  
  26.     cout << "\t\t最小值:" << (numeric_limits<short>::min)() << endl;  
  27.     cout << "int: \t\t" << "所占字节数:" << sizeof(int);  
  28.     cout << "\t最大值:" << (numeric_limits<int>::max)();  
    👄🍊🈳🐕‌
  29.     cout << "\t最小值:" << (numeric_limits<int>::min)() << endl;  
  30.     cout << "unsigned: \t" << "所占字节数:" << sizeof(unsigned);  
  31.     cout << "\t最大值:" << (numeric_limits<unsigned>::max)();  
  32.     cout << "\t最小值:" << (numeric_limits<unsigned>::min)() << endl;  
  33.     cout << "long: \t\t" << "所占字节数:" << sizeof(long);  

    🧑‍🌾‎👜🔑💀🖕


  34.     cout << "\t最大值:" << (numeric_limits<long>::max)();  
  35.     cout << "\t最小值:" << (numeric_limits<long>::min)() << endl;  
  36.     cout << "unsigned long: \t" << "所占字节数:" << sizeof(unsigned long);  
  37.     cout << "\t最大值:" << (numeric_limits<unsigned long>::max)();  
  38.     cout << "\t最小值:" << (numeric_limits<unsigned long>::min)() << endl;  👩‍✈️‍👗🪟🤡
  39.     cout << "double: \t" << "所占字节数:" << sizeof(double);  
  40.     cout << "\t最大值:" << (numeric_limits<double>::max)();  
  41.     cout << "\t最小值:" << (numeric_limits<double>::min)() << endl;  
  42.     cout << "long double: \t" << "所占字节数:" << sizeof(long double);  
  43.     cout << "\t最大值:" << (numeric_limits<long double>::max)();  🧑‍🍳‏🧢🔋😡👎
  44.     cout << "\t最小值:" << (numeric_limits<long double>::min)() << endl;  
  45.     cout << "float: \t\t" << "所占字节数:" << sizeof(float);  
  46.     cout << "\t最大值:" << (numeric_limits<float>::max)();  
  47.     cout << "\t最小值:" << (numeric_limits<float>::min)() << endl;  
  48.     cout << "size_t: \t" << "所占字节数:" << sizeof(size_t);  🥷‌👖📞😂🦴
  49.     cout << "\t最大值:" << (numeric_limits<size_t>::max)();  
  50.     cout << "\t最小值:" << (numeric_limits<size_t>::min)() << endl;  
  51.     cout << "string: \t" << "所占字节数:" << sizeof(string) << endl;  
  52.     // << "\t最大值:" << (numeric_limits<string>::max)() << "\t最小值:" << (numeric_limits<string>::min)() << endl;  
  53.     cout << "type: \t\t" << "************size**************"<< endl;  🧓‎🎩💶😉

  54.     return 0;  
  55. }  
复制代码


🤟🏦🔪❌🦜‏
an8 「初入古黑」 2016-9-16 10:07 来自手机 |显示全部楼层

这个用户很懒,还没有填写自我介绍呢~

  c语言允许整数型变量赋以字符型变量
短整数型为两个字节,字符型为一个字节

往后学,再学低级语言...
三星半月 「初入古黑」 2016-9-16 22:25 来自手机 |显示全部楼层

这个用户很懒,还没有填写自我介绍呢~

引用

小执念 发表于 2016-09-16 10:24:41
1.发错板块,下不为例。2.C语言中规定char类型占一个字


💪🌕🍇🈷🪶‍明白了,谢谢,要发在语言编程这个板块对吧
弓长张 「出类拔萃」 2016-9-25 21:26 来自手机 |显示全部楼层

这个用户很懒,还没有填写自我介绍呢~

一脸懵逼
初晓微芒 「出类拔萃」 2018-5-3 06:06 |显示全部楼层

这个用户很懒,还没有填写自我介绍呢~

纯粹路过,没任何兴趣,仅仅是看在论坛币份上回复一下#j326:
屋顶,数星星 「出类拔萃」 2018-5-3 17:23 |显示全部楼层

这个用户很懒,还没有填写自我介绍呢~

感谢分享~
hhjj543212012 「龙战于野」 2019-2-25 08:22 |显示全部楼层

这个用户很懒,还没有填写自我介绍呢~

感谢分享
糟糕!hhjj543212012长得太帅路遇劫匪,赎金 1 个 金币.
您需要登录后才可以回帖 登录 | 免费注册  

本版积分规则

快速回复 返回列表