Part 1. 题目描述 (easy) Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have exactly one solution, and you may not use the same element twice. Example: Given n
问题1 用来测试的,就不说了 问题2:中位数附近2k+1个数 给出一串整型数 a1,a2,...,an 以及一个较小的常数 k,找出这串数的中位数 m 和最接近 m 的小于等于 m 的 k 个数,以及最接近 m 的大于等于 m 的 k 个数.将这 2k+1 个数按升序排序后输出. 中位数定义:如果数串的大小是偶数 2j,中位数是从小到大排列的第 j 个数:如果数串的大小是奇数 2j+1,中位数是从小到大排列的第 j+1 个数. 输入 第一行是 k 的值和数串的长度 n. 第二行是以空格隔开的 n
判断两整数是否异号: int x, y; //输入比较的两数 bool f = ((x ^ y) < 0); // 返回真,当且仅当x与y异号 说明:当x.y异号,x与y的最高位分别为0和1,取"^"后为1,结果为负数 不用选择语句得到指定整数的绝对值: int v; // 需要得到整数v的绝对值 unsigned int r; // r保存结果 int const mask = v >> sizeof(int) * CHAR_BIT - 1; r = (v + ma