预处理、const、static、sizeof
1.预处理和宏定义
#define xxxx
#ifdef
xxxx ;
#elseif
xxxx;
#endif
2.c++求随机数
rand(),rand()会返回一随机数值, 范围在0至RAND_MAX 间
#define random(x) (rand()%x),产生0~x区间的随机数
但,以上都是产生一次随机数,srand()用来设置rand()产生随机数时的随机数种子。
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#define random(x) (rand()%x) void main()
{ srand((int)time(0));
for(int x=0;x<10;x++) {
printf("%d/n",random(100));
}
}
预处理、const、static、sizeof的更多相关文章
- 程序员面试宝典 笔记(第六章 预处理 const 和sizeof())
void main() { "; cout<< cout<< "; cout<< cout<<strlen(ss2)<< ...
- const,static,extern 简介
const,static,extern 简介 一.const与宏的区别: const简介:之前常用的字符串常量,一般是抽成宏,但是苹果不推荐我们抽成宏,推荐我们使用const常量. 执行时刻:宏是预编 ...
- 李洪强iOS经典面试题155 - const,static,extern详解(面试必备)
李洪强iOS经典面试题155 - const,static,extern详解(面试必备) 一.const与宏的区别(面试题): const简介:之前常用的字符串常量,一般是抽成宏,但是苹果不推荐我们抽 ...
- const ,static,inline
const: 1 定义变量 ,如下写法都可以: TYPE const ValueName = value; const TYPE ValueName = value; ...
- const, static and readonly
const, static and readonly http://tutorials.csharp-online.net/const,_static_and_readonly Within a cl ...
- 类内const static(static const)成员变量初始化问题
在查找const相关资料的过程中,又遇到了另外一个问题,就是C++类中const static(或者static const)成员变量应当如何初始化的问题. 查阅了许多资料,发现VC环境下,只允许co ...
- 【转】forbids in-class initialization of non-const static member不能在类内初始化非const static成员
转自:forbids in-class initialization of non-const static member不能在类内初始化非const static成员 今天写程序,出现一个新错误,好 ...
- c++ const static
const作用: 1.定义常量,可以保护被修饰的东西,防止意外的修改,增强程序的健壮性. const int Max = 100; void f(const int i) { i=10;//error ...
- PHP中const,static,public,private,protected的区别
原文地址:http://small.aiweimeng.top/index.php/archives/54.html const: 定义常量,一般定义后不可改变static: 静态,类名可以访问pub ...
- PHP对象5: define / const /static
define定义全局常量: define('PATH', '/data/home/www'); const也是定义常量, 一般用于类中, 饰成员属性,不可以修饰方法,如下: class Test{ c ...
随机推荐
- Mysql net start mysql启动,提示发生系统错误 5 拒绝訪问 解决之道
当前用户的操作权限太低了,出了问题 出错问题截屏例如以下: watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/4 ...
- LeetCode 350. Intersection of Two Arrays II (两个数组的相交之二)
Given two arrays, write a function to compute their intersection. Example:Given nums1 = [1, 2, 2, 1] ...
- vs2008C1902程序数据库管理不匹配
大清早打开vs2008,出现这么诡异的错, 删了一个dll的就好了.如图
- 初识bigdata时的一些技能小贴士
既然小豆腐如此给力,而且充分的利用主动学习的优势,已经有了迅速脑补,压倒式的优势,不过这只是表面而已,一切才刚刚开始,究竟鹿死谁手,还有待验证. 以上可以看到,小豆腐为什么拼命的要teach我们了么, ...
- Ubuntu 16.04 安装CodeBlocks
首先将软件源添加进来,就是运行以下命令 sudo add-apt-repository ppa:damien-moore/codeblocks-stable sudo apt-get update 完 ...
- SQL分离附加数据库
转自:http://www.jb51.net/article/36624.htm
- 怎么看待MYSQL的性能
MySQL在单实例性能方面和Oracle相比还有一些差距,我们通过规范和技术手段来降低这些性能差距带来的问题. 首先,大量甚至海量数据的增删改.查询.聚合查询的性能还有待提高.为了规避这些问题,我们在 ...
- 51. ExtJs4之Ext.util.JSON编码和解码JSON对象
转自:https://blog.csdn.net/iteye_9439/article/details/82518158 1.decode() 该方法用于将符合JSON格式的String进行解码成为一 ...
- gulp的使用安装
gulp安装:用cnpm的时候把npm换成cnpm就好了. npm install -g gulp(全局安装,安装一次就好) npm install --save-dev gulp(安装到项目目录下, ...
- [Swift通天遁地]九、拔剑吧-(12)创建Preview-Transition图像预览界面
★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★➤微信公众号:山青咏芝(shanqingyongzhi)➤博客园地址:山青咏芝(https://www.cnblogs. ...