Chinaunix首页 | 论坛 | 博客
  • 博客访问: 99305
  • 博文数量: 102
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1011
  • 用 户 组: 普通用户
  • 注册时间: 2014-01-15 13:58
个人简介

普普通通一个人

文章分类

全部博文(102)

文章存档

2018年(1)

2015年(13)

2014年(88)

我的朋友

分类: C/C++

2014-02-04 06:32:43


点击(此处)折叠或打开

  1. #include <stdio.h>
  2. float mypower(int);

  3. int main(void){
  4.     char c;
  5.     short s;
  6.     int i;
  7.     long l;
  8.     unsigned u;
  9.     float f;
  10.     double d;
  11.     long double ld;
  12.     int a[20];
  13.     int *ptr = a;

  14.     printf("size of char is %d\t"
  15.         "the kinds of char is %0.f\n"
  16.         "size of short is %d\t"
  17.         "the kinds of short is %0.f\n"
  18.         "size of int is %d\t"
  19.         "the kinds of int is %0.f\n"
  20.         "size of long is %d\t"
  21.         "the kinds of long is %0.f\n"
  22.         "size of unsigned is %d\t"
  23.         "the kinds of unsigned is %0.f\n"
  24.         "size of float is %d\t"
  25.         "the kinds of float is %0.f\n"
  26.         "size of double is %d\t"
  27.         "the kinds of double is %0.f\n"
  28.         "size of long double is %d\t"
  29.         "the kinds of long double is %0.f\n"
  30.         "size of array is %d\t"
  31.         "the kinds of array is %0.f\n"
  32.         "size of pointer is %d\t"
  33.         "the kinds of pointer is %0.f\n",
  34.         sizeof(c), mypower(sizeof(c)),
  35.         sizeof(s), mypower(sizeof(s)),
  36.         sizeof(i), mypower(sizeof(i)),
  37.         sizeof(l), mypower(sizeof(l)),
  38.         sizeof(u), mypower(sizeof(u)),
  39.         sizeof(f), mypower(sizeof(f)),
  40.         sizeof(d), mypower(sizeof(d)),
  41.         sizeof(ld), mypower(sizeof(ld)),
  42.         sizeof(a), mypower(sizeof(a)),
  43.         sizeof(ptr)),mypower(sizeof(ptr));

  44.     return 0;
  45.     
  46. }

  47. float mypower(int x){
  48.     float base = 1.0;
  49.     for (int i = 1; i <= (8 * x); i++)
  50.     {
  51.         base = 2 * base;
  52.     }

  53.     return base;
  54. }

阅读(183) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~