摘要: #include <stdio.h> int main() { int a;float b; scanf("a=%d,b=%f",&a,&b); printf("%d,%f\n",a,b); printf("%d\n",a+(int)b); getchar(); } 阅读全文
posted @ 2021-04-27 18:24 myrj 阅读(505) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h> //强制类型转换 //写法:(类型标识符)变量;(类型标识符)常量;(类型标识符)(表达式);三种格式 main() { float a=7.5f; long b=100L; printf("%d,%d\n",sizeof(a),sizeof(b)); prin 阅读全文
posted @ 2021-04-27 06:41 myrj 阅读(324) 评论(0) 推荐(0) 编辑
摘要: float类型%d输出 float a=7.5f; 如果用printf("%d",a);输出的是0。 但float型用%d输出是否一定是0呢,答案肯定不都是0; 为什么 7.5 用%d输出的是0?分析如下: 首先来了解下printf的输出格式,int 和 long int 都是32位的,用%d输出; 阅读全文
posted @ 2021-04-27 06:20 myrj 阅读(5896) 评论(0) 推荐(0) 编辑
摘要: float a=7.5f; //7.5为浮点数 long b=100L; //100为长整数 int c=0123;// 0123为8进制数 int d=0x123;//0x123为16进制数 阅读全文
posted @ 2021-04-27 06:00 myrj 阅读(443) 评论(0) 推荐(0) 编辑