EEWiKi
首页
  • 命名数据网络
  • 论文笔记
  • 机器学习
  • 研学周报
  • C++
  • Python
  • 计算机网络
  • 数据结构与算法
  • 计算机组成原理
  • 操作系统
  • 英语学习
  • 面试
  • 运动
  • 生活读书杂货
  • 实用技巧
  • 软件使用安装
最近更新
GitHub (opens new window)
首页
  • 命名数据网络
  • 论文笔记
  • 机器学习
  • 研学周报
  • C++
  • Python
  • 计算机网络
  • 数据结构与算法
  • 计算机组成原理
  • 操作系统
  • 英语学习
  • 面试
  • 运动
  • 生活读书杂货
  • 实用技巧
  • 软件使用安装
最近更新
GitHub (opens new window)
  • C++

    • 侯捷C++面向对象
    • C++基础
    • STL
    • C++
      • C++基础知识
        • 基本语法
        • 毕设遇到的编程问题:
        • C++生成随机数?
    • C语言
  • Python

  • shell

  • 编程语言
  • C++
peirsist
2022-05-21
目录

C++

# C++基础知识

# 基本语法

  1. sprintf()函数:将格式化的数据写入字符串_C语言中文网 (opens new window)
    • sprintf()的作用是将一个格式化的字符串输出到一个目的字符串中,而printf()是将一个格式化的字符串输出到屏幕。
    • int sprintf(char *str, char * format [, argument, ...])。str为要写入的字符串;format为格式化字符串,与printf()函数相同;argument为变量。
  2. fscanf()函数:将文件流中的数据格式化输入_C语言中文网 (opens new window)
  3. C++基础之uint8_t_时光机 °的博客-CSDN博客 (opens new window)
  4. 浅析C语言之uint8_t / uint16_t / uint32_t /uint64_t_海阔天空sky的博客-CSDN博客 (opens new window)
  5. 求一个数组中出现次数超过n/3的数(C++实现)_zhanyue666的博客-CSDN博客 (opens new window)
  6. 开学回归力扣:第十二题—— 229. 求众数 II(摩尔投票法)_xiangguang_fight的博客-CSDN博客 (opens new window)

# 毕设遇到的编程问题:

2021年3月24日

  • C语言全局变量多个cpp,c++多个文件中共用一个全局变量 变量跨文件使用_李勖晟的博客-CSDN博客 (opens new window)
  • C++将一个cpp文件中的变量应用到另一个cpp文件中_公子恒的博客-CSDN博客 (opens new window)
  int i; //声明并定义 
  extern int i; //声明 
  extern int i=10; //定义 
   
  void f(); //声明 
  void f() {}; //定义

提示

  • C++ getline函数用法详解 (biancheng.net) (opens new window)
  • C 库函数 – strcpy() | 菜鸟教程 (runoob.com) (opens new window)
  • string中c_str()的用法_Lemonbr的博客-CSDN博客_string.c_str (opens new window)
  • C++强制类型转换操作符 static_cast - melonstreet - 博客园 (cnblogs.com) (opens new window)
  • C++类型转换之reinterpret_cast - 知乎 (zhihu.com) (opens new window)
  • C++ 报错 error: ‘xxx’ was not declared in this scope_wongHome的博客-CSDN博客 (opens new window)
  • const char * 、char const *、 char * const 三者的区别_SilentOB的博客 (opens new window)
  • C++中const char*, string 与char*的转化_风居住de街道的博客-CSDN博客 (opens new window)
  • C++ 中 string和char* 的区别 - Tsingke - 博客园 (cnblogs.com) (opens new window)
  • C++ 内存溢出&内存泄漏_AiChiMomo.的博客-CSDN博客_c++ 内存溢出 (opens new window)
  • 从缓冲系统文件到常见栈溢出函数_Retrovich的博客-CSDN博客_函数栈溢出 (opens new window)
  • 文件读写完后fclose()就内存溢出-CSDN社区 (opens new window)
  • C语言自定义函数如何返回数组_renyuxiaomei的博客-CSDN博客_返回数组的函数怎么写 (opens new window)
  • 用数组作为函数返回值_Gavechan的博客-CSDN博客_数组作为返回值 (opens new window)
  • 错误信息was not declared in this scope (opens new window)
  • C++, 想要使用string ,必须要用命名空间 std (opens new window)

# C++生成随机数?

  • C++产生随机数_on_june_7th的博客-CSDN博客_c++随机数 (opens new window)
  • C++中rand()函数的用法_风暴计划的博客-CSDN博客_c++ rand() (opens new window)
  • C++寻找数组最大值和最小值_Jeff_的博客-CSDN博客_c++求数组中的最大值和最小值 (opens new window)

rand() 不需要参数,它会返回一个从 0 到最大随机数的任意整数,最大随机数的大小通常是固定的一个大整数。int num = rand() % 100 ; 所以,num的值就是一个 0~99 中的一个随机数了。

如果要产生 1~100 ,则是这样:

int num = rand() % 100 + 1; 

总结来说,可以表示为: int num = rand() % n +a; 其中的 a 是起始值, n-1+a 是终止值, n 是整数的范围。

一般性 :rand() % (b-a+1)+ a; 就表示 a~b 之间的一个随机整数。

若要产生 0-1 之间的小数,则可以先取得 0-10的整数,然后均除以 10 即可得到“随机到十分位”的 10 个随机小数。

通常 rand() 产生的随机数在每次运行的时候都是与上一次相同的,这样是为了便于程序的调试。

若要产生每次不同的随机数,则可以使用 srand( seed ) 函数进行产生随机化种子,随着seed的不同,就能够产生 不同的随机数。

上次更新: 2022/06/15, 02:31:28
STL
C语言

← STL C语言→

最近更新
01
极大似然估计
08-11
02
C++基础
08-11
03
STL
08-11
更多文章>
Theme by Vdoing | Copyright © 2022-2022 peirsist | 早睡,运动,读书
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式