C/C++实践笔记 005

整型常量
int a=101u; 无符号整数
int b=102l; 长整数
int c=103ll; long long整数 存储qq号,手机号

010八进制 0x10十六进制


嵌入式的场合经常用short int,int可以省略


int,long int在32位以上的机器等价,4个字节


16位的单片机 int shortint等价,2个字节


unsigned int 极大值大于int,缺点是不能表示负数


int默认有符号,signed省略


long long num=13804393838; 存储qq号,手机号
printf("%lld",num);

unsigned long long存储身份证号

实数编程
浮点数
%f实数

赋值号会自动转换类型,printf不会。

e或E为10,指数只能是整数

海量数据一般用指数表示
float单精度4个
double双精度8个
long double 大于等于double


==成立是1,不成立是0

float有效数字6-7位,后续就不看了
double不能超过15位

#include<float.h>

"%.100f"保留小数点后100位

#include<math.h>
#include<stdlib.h>
#include<stdio.h>


void main()
{

double a=3.4,b=5.6,c=8;
double p =(a+b+c)/2;
double S=sqrt(p*(p-a)*(p-b)*(p-c));

//*不能省略


}
#include<stdio.h>
#include<math.h>
#include<windows.h>
void main()
{
double ch = 10.0;
double am = 17.0; //底数
double chd = 1.07;
double amd = 1.03; //增长率

for (int i = 1; i <= 100; i++)

{

printf("\n中国第%d年GDP=%f万亿美金",2014+i,ch*pow(chd,i));

}

getchar();
}

 

posted @ 2016-09-19 11:32  千年风雅丶  阅读(255)  评论(0编辑  收藏  举报