点击(此处)折叠或打开
- #include <stdio.h>
- float mypower(int);
-
- int main(void){
- char c;
- short s;
- int i;
- long l;
- unsigned u;
- float f;
- double d;
- long double ld;
- int a[20];
- int *ptr = a;
-
- printf("size of char is %d\t"
- "the kinds of char is %0.f\n"
- "size of short is %d\t"
- "the kinds of short is %0.f\n"
- "size of int is %d\t"
- "the kinds of int is %0.f\n"
- "size of long is %d\t"
- "the kinds of long is %0.f\n"
- "size of unsigned is %d\t"
- "the kinds of unsigned is %0.f\n"
- "size of float is %d\t"
- "the kinds of float is %0.f\n"
- "size of double is %d\t"
- "the kinds of double is %0.f\n"
- "size of long double is %d\t"
- "the kinds of long double is %0.f\n"
- "size of array is %d\t"
- "the kinds of array is %0.f\n"
- "size of pointer is %d\t"
- "the kinds of pointer is %0.f\n",
- sizeof(c), mypower(sizeof(c)),
- sizeof(s), mypower(sizeof(s)),
- sizeof(i), mypower(sizeof(i)),
- sizeof(l), mypower(sizeof(l)),
- sizeof(u), mypower(sizeof(u)),
- sizeof(f), mypower(sizeof(f)),
- sizeof(d), mypower(sizeof(d)),
- sizeof(ld), mypower(sizeof(ld)),
- sizeof(a), mypower(sizeof(a)),
- sizeof(ptr)),mypower(sizeof(ptr));
-
- return 0;
-
- }
-
- float mypower(int x){
- float base = 1.0;
- for (int i = 1; i <= (8 * x); i++)
- {
- base = 2 * base;
- }
-
- return base;
- }
相关热门文章
给主人留下些什么吧!~~
评论热议