C语言
hacker&cracker
这个作者很懒,什么都没留下…
展开
-
给定一个整数,在一个整数数组中找到两个下标不同的元素,其和为给定的整数
#include<stdio.h> #include<stdlib.h> #include"uthash.h" typedef struct hash_map { int key; int value; UT_hash_handle hh; } HashMap; HashMap* map = NULL; HashMap* find(int key) { HashMap* temp = NULL; HASH_FIND_INT(map, &原创 2021-02-16 16:54:46 · 218 阅读 · 0 评论 -
两个整数相加减是否溢出
#include<stdio.h> #include<stdint.h> // 两个整数相加减,没有溢出时返回0 int tadd_ok(int x, int y) { int sum = x + y; int neg_over = x < 0 && y < 0 && sum >= 0; int pos_over = x > 0 && y > 0 && sum < 0; re原创 2021-02-09 19:36:21 · 386 阅读 · 0 评论