C++学习笔记2019-06-12

From now on, I will begin to learn C++, starting with C++ primer. What is a program? Programs usually contain algorithms and data sets. Algorithms or instructions tell you how to do this. Data sets are operational objects. For example, eating, rest and so on can be regarded as algorithms, sometimes the algorithm involves more than one object of operation.A simple C++ program has been listed below.

#include<iostream>

#include<ctime>

#include<cstdlib>

using namespace std;

void sleep(void){ cout<<"sleep"<<endl;}

void eat(void){ cout<<"eat"<<endl;}

void study(void){ cout<<"study"<<endl;}

int main()

{

int i=1;

while(1)

{

cout<<"The loop count:"<<i<<endl;

srand((unsigned)time(NULL));

int a;

a=rand()%(3-0+1)+0;

cout<<"a="<<a<<endl;

if(a>2||a<0) cout<<"error!"<<endl;

if(a==0) sleep();

if(a==1) eat();

if(a==2) study();

//else cout<<"error"<<endl;

i++;

for(int j=0;j<1000000000;j++);

}

}

Reference

【1】https://blog.csdn.net/beyond0824/article/details/6009908

【2】https://blog.csdn.net/u014571489/article/details/82258467

【3】https://blog.csdn.net/qq_21808961/article/details/78204418

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容