// rand.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include<iostream>
#include"time.h"//系统时间头文件,函数srand()与rand所在的头文件
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
const int i = 10;//consr为常数限定符其定义值不可更改;
const double k = 25.66E3;
const double j = 25.67e-4;//e-4为25.67/10的4次方,e+4为25.67*10的4次方 e+为小数点右移,e-为小数点左移,浮点的意思为小数点可以移动
srand(time(NULL));//生成随机数种子
cout<<"常数j"<<j<<"\n常数k"<<k<<"\n常数i"<<i<<"\n随机数"<<rand()%100<<endl;//生成不大于100的随机数
const int n = 5;
char m[n];
cin.get(m,n);//cin>>通常只能读取一个单词。cin.get()可以读取固定长度的字符串,含空格等符号。
cout<<m<<endl;
cin.get();
cin.get();//判断回车键是否按下
return 0;
}
c++,随机数生成与cin.get(的使用方法)
最新推荐文章于 2024-06-16 17:03:09 发布