数据与C
//以十进制、八进制和十六进制输出100,加入#会显示前缀
#include<stdio.h>
int main()
{
int x = 100;
printf("dec = %d; octal = %o;hex = %x\n",x,x,x);
printf("dec = %d; octal = %#o;hex = %#x\n",x,x,x);
return 0;
}
//整数溢出
#include<stdio.h>
int main()
{
int i = 2147483647;
unsigned int j = 4294967295;
printf("%d %d %d\n",i,i+1,i+2);
printf("%u %u %u\n",j,j+1,j+2);
return 0;
}
//printf()更多的属性
#include<stdio.h>
int main()
{
unsigned int un = 3000000000;
short end = 200;
long big = 65537;
const __int64 verybig = 12345678908642;//long long 我的编译器不支持
printf("un = %u and not %d\n",un,un);
printf("end = %hd and %d\n",end,end);
printf("big = %ld and %hd\n",big,big);
printf("verybig= %lld and not %ld\n",verybig,verybig);
printf("%d\n",sizeof(__int64));
return 0;
}
//显示一个字符的编码值
#include<stdio.h>
int main()
{
char ch;
printf("Please enter a character.\n");
scanf("%c",&ch);
printf("The code for %c is %d.\n",ch,ch);
return 0;
}
//可移植的整数类型名
#include<stdio.h>
#include<inttypes.h>
int main(void)
{
int16_t me16;
me16 = 4593;
printf("Frist,assume int16_t is short:");
printf("me16 = %hd\n",me16);
printf("Next,let's not make any assumptions.\n" );
printf("Instead,use a \"macro\" from inttypes.h: ");
printf("me16 = %" PRID16"\n",me16);
return 0;
}
//%f 与%e的转换
#include<stdio.h>
int main()
{
float about = 32000.0;
double abet = 2.14e9;
long double dip = 5.32e-5;
printf("%f can be written %e\n",about,about);
printf("%f can be written %e\n",abet,abet);
printf("%f can be written %e\n",dip,dip);
return 0;
}
//float 在系统假设最大值为3.4E38时,下面代码会发生上溢
#include<stdio.h>
int main()
{
float toobig = 3.4E38 * 100.0f;
printf("%e\n",toobig);
}
//结果不等于1,因为计算机缺乏足够的进行正确运算所需的十进制位数。
//数字2.0e20为2后面加上20个零,如果对它加一改变的将是第21位,而float只有6,7位有效位数
#include<stdio.h>
int main()
{
float a,b;
b = 2.0e20 +1.0;
a = b - 2.0e20;
printf("%f \n",a);
return 0;
}
/*输出类型的大小*/
#include<stdio.h>
int main()
{
printf("Type int has a size of %lu bytes.\n",sizeof(int));
printf("Type char has a size of %u bytes.\n",sizeof(char));
printf("Type long has a size of %u bytes.\n",sizeof(long));
printf("Type double has a size of %u bytes.\n",
sizeof(double));
return 0;
}
//将浮点值变为整数,c简单地丢弃小数部分(截尾),而不进行四舍五入
#include<stdio.h>
int main()
{
int cost = 3.5415926;
printf("%d\n",cost);
}
/*
printf中参数不足和类型不匹配所造成的结果随平台的不同而不同。
%d显示float值不会进行转换,而是显示垃圾值,其他类型也一样
*/
#include<stdio.h>
int main()
{
int f = 4;
int g = 5;
float h = 5.0f;
printf("%d\n",f,g);
printf("%d %d\n",f);
printf("%d %f\n",h,g);
return 0;
}
//转义字符
#include<stdio.h>
int main()
{
float salary ;
printf("\aEnter your desired monthly salary:");
printf(" $_______\b\b\b\b\b\b\b");
scanf("%f",&salary);
printf("\n\t$%.2f a month is $%.2f a year.",salary,
salary*12.0);
printf("\rGee!\n");
return 0;
}
数据与C的更多相关文章
- Hadoop 中利用 mapreduce 读写 mysql 数据
Hadoop 中利用 mapreduce 读写 mysql 数据 有时候我们在项目中会遇到输入结果集很大,但是输出结果很小,比如一些 pv.uv 数据,然后为了实时查询的需求,或者一些 OLAP ...
- App开发:模拟服务器数据接口 - MockApi
为了方便app开发过程中,不受服务器接口的限制,便于客户端功能的快速测试,可以在客户端实现一个模拟服务器数据接口的MockApi模块.本篇文章就尝试为使用gradle的android项目设计实现Moc ...
- 使用TSQL查询和更新 JSON 数据
JSON是一个非常流行的,用于数据交换的文本数据(textual data)格式,主要用于Web和移动应用程序中.JSON 使用“键/值对”(Key:Value pair)存储数据,能够表示嵌套键值对 ...
- SQL Server 大数据搬迁之文件组备份还原实战
一.本文所涉及的内容(Contents) 本文所涉及的内容(Contents) 背景(Contexts) 解决方案(Solution) 搬迁步骤(Procedure) 搬迁脚本(SQL Codes) ...
- SQLSERVER将一个文件组的数据移动到另一个文件组
SQLSERVER将一个文件组的数据移动到另一个文件组 有经验的大侠可以直接忽视这篇文章~ 这个问题有经验的人都知道怎麽做,因为我们公司的数据量不大没有这个需求,也不知道怎麽做实验 今天求助了QQ群里 ...
- 【.net 深呼吸】设置序列化中的最大数据量
欢迎收看本期的<老周吹牛>节目,由于剧组严重缺钱,故本节目无视频无声音.好,先看下面一个类声明. [DataContract] public class DemoObject { [Dat ...
- Scrapy框架爬虫初探——中关村在线手机参数数据爬取
关于Scrapy如何安装部署的文章已经相当多了,但是网上实战的例子还不是很多,近来正好在学习该爬虫框架,就简单写了个Spider Demo来实践.作为硬件数码控,我选择了经常光顾的中关村在线的手机页面 ...
- 通过AngularJS实现前端与后台的数据对接(二)——服务(service,$http)篇
什么是服务? 服务提供了一种能在应用的整个生命周期内保持数据的方法,它能够在控制器之间进行通信,并且能保证数据的一致性. 服务是一个单例对象,在每个应用中只会被实例化一次(被$injector实例化) ...
- 恢复SQL Server被误删除的数据(再扩展)
恢复SQL Server被误删除的数据(再扩展) 大家对本人之前的文章<恢复SQL Server被误删除的数据> 反应非常热烈,但是文章里的存储过程不能实现对备份出来的日志备份里所删数据的 ...
- 将表里的数据批量生成INSERT语句的存储过程 增强版
将表里的数据批量生成INSERT语句的存储过程 增强版 有时候,我们需要将某个表里的数据全部或者根据查询条件导出来,迁移到另一个相同结构的库中 目前SQL Server里面是没有相关的工具根据查询条件 ...
随机推荐
- IOS学习笔记27—使用GDataXML解析XML文档
http://blog.csdn.net/ryantang03/article/details/7868246
- 一简单的RPC实例(Java)
来至于阿里liangf:如有冒犯,请原谅 RPCFrameWork: package com.sunchao.demo; import java.io.IOException; import java ...
- mysql 分组和聚合函数
mysql 分组和聚合函数 Mysql 聚集函数有5个: 1.COUNT() 记录个数(count(1),count(*)统计表中行数,count(列名)统计列中非null数) 2.MAX() 最大值 ...
- 前端css常用class命名id命名
1.常用id的命名: (1)页面结构 容器: container 页头:header 内容:content/container 页面主体:main 页尾:footer 导航:nav 侧栏:sideba ...
- 判断具有某个属性js、jQuery
if(!rr.classList.contains('invalid')){ updateCount(i,-1);//更新tab数量 } /*if(!$(rr).hasClass('invalid') ...
- java8大基本数据类型
基本类型 字节数 位数 最大值 最小值 byte 1byte 8bit 2^7 - 1 -2^7 short 2byte 16bit 2^15 - 1 -2^15 int 4byte 32bit 2^ ...
- PHP7.1 报错 Warning Illegal string offset
报错如下: Warning: Illegal string offset '阿根廷' in F:\wnmp\www\test.php on line 24 Warning: Illegal strin ...
- wampserver 的Apache启动错误提示:The requested URL / was not found on this server.
打开localhost显示以下错误 原因:之前我配置了虚拟主机,所以服务器是从虚拟环境访问的,localhost也就访问不到 解决方法:打开httpd.conf配置文件,将Include conf/e ...
- Unity3d 基本设计开发 原则(提高代码可读性)
参考:http://blog.csdn.net/qq_34134078/article/details/51780356 1.单一原则 即:明确类的定义.通俗来讲,让他们只做一件事,而不是多件事. 提 ...
- python字符串问题
相关知识点: 字符串在Python内部的表示是unicode编码,因此,在做编码转换时,通常需要以unicode作为中间编码,即先将其他编码的字符串解码(decode)成unicode,再从unico ...