随笔分类 - C/C++算法
主要一些基础算法
摘要:求一个整数的二进制中1的个数 收藏题目:输入一个整数,求该整数的二进制表达中有多少个1。例如输入10,由于其二进制表示为1010,有两个1,因此输出2。分析:这是一道很基本的考查位运算的面试题。包括微软在内的很多公司都曾采用过这道题。一个很基本的想法是,我们先判断整数的最右边一位是不是1。接着把整数...
阅读全文
摘要:#define _CRT_SECURE_NO_WARNINGS#include #include#include//C语言声明变量需要加上stuct//C语言结构内部不可以有函数//C语言结构体没有公有,私有,继承struct MyStruct{ int num1; int num2...
阅读全文
摘要:#include #include "stdlib.h"#define MAX(X,Y)(((X)>(Y))?(X):(Y))#define MAX(X,Y)(((X)<(Y))?(X):(Y))#define SQR(X) (X*X)#define DEBUGint main(){ int ...
阅读全文
摘要://// main.cpp// test//// Created by YaguangZhu on 15/6/25.// Copyright (c) 2015年 YaguangZhu. All rights reserved.//#include #include "stdlib.h"#de...
阅读全文
摘要:对所有的三位数乘两位数 判断其过程中出现的数值都是 输入的数字中的#include #include using namespace std;int main(){ char s[20],buff[100]; scanf("%s",s); int abc,de,x,y,z,flag...
阅读全文
摘要:#include #include int main(){ int n=0; int score =0; int score_hight = 0; int score_low = 101; char name [10]={0}; char name_low...
阅读全文
摘要:#include #include #include using namespace std;int n,l[15];bool h[10000];bool is_triangle(int a,int b,int c) { return !h[a * 100 + b] && a && b ...
阅读全文

浙公网安备 33010602011771号