一些杂的知识点*

众数是指在一组数据中,出现次数最多的数

在C++ 中可看到某个数x*1LL 可以把x变为long long 型的

在C语言中
需要这样初始化一维和二维数组

int test0[] = { 0,1,2,3 };
int test1[][4]={ {0,1,2,3}, {4,5,6,7}, {8,9,10,11}, {12,13,14,15} };

其中二维数组的列数必须给出

C语言中用位运算判断奇偶需注意
if(n&1==0)是错的 ,因为 ==先运算,所以 ==运算的结果为0,则变成了if(n&0)始终是false的
要么if(n&1) 要么if((n&1)==0)

#include <stdio.h>
#include <stdlib.h> 
#include <time.h>

int main()
{
    srand((unsigned int)time(NULL));     // 设置随机数种子,只要不在time函数的精度内调用两次程序,则这两次程序的随机数序列是不同的 
    for (int i = 0; i < 10; i++)
    {
        printf("%u\n", rand());
    }
    getchar();
    return 0;
}

mt19937用来产生大的随机数(伪随机数?)
种子分别取
random_device{}()
time(0)
std::chrono::system_clock::now().time_since_epoch().count()

std::mt19937 mt_rand(std::random_device{}());
std::mt19937 mt_rand(time(0));
std::mt19937 mt_rand(std::chrono::system_clock::now().time_since_epoch().count());

int 最大值 0x7ffffff
最小值 0x8000000

在leetcode中 (l+r)>>1+1是错的,+会先运算 所以要((l+r)>>1)+1

unordered_map中 定义了一个mp
mp[3]++后mp自动mp[3]=1

#include<stdio.h>
int main()
{
    int a;
    scanf("%d", &a);
    int b = a * 0.2;
    printf("%d", a*0.2);
    return 0;
}

这样的话不论a输入什么10的倍数 都会输出0 为什么

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值