您正在查看: 6Green理工人 发布的文章
判断101到200之间的素数
程序分析:判断素数的方法:用一个数分别去除2到sqrt(这个数),如果能被整除, 则表明此数不是素数,反之是素数。#include <stdio.h>
int main()
{
int i,j;
int count=0;
for (i=101; i<=200; i++)
{
for (j=2; j<i; j...阅读全文
C与C++的10个主要不同点
如上图那样,C++,英文为c plus plus,它是C的超级,C++支持运行大部分C代码,而反过来C却不可以;这里例举了它们之间的主要10个不同点(为了不偏离原本的语意,直接上英文了):1、C follows the procedural programming paradigm while C++ is a multi-paradigm(多范式) language(procedural ...阅读全文
C/C++获取进程常驻内存大小(get the process resident set size )
1、进程内存接口函数2、接口封装实现#if defined(_WIN32)
#include <windows.h>
#include <psapi.h>
#elif defined(__unix__) || defined(__unix) || defined(unix) || (defined(__APPLE__) && defined(__MA...阅读全文
C/C++获取系统物理内存大小
1、各平台调用接口2、接口实现
#if defined(_WIN32)
#include <Windows.h>
#elif defined(__unix__) || defined(__unix) || defined(unix) || (defined(__APPLE__) && defined(__MACH__))
#include <unistd....阅读全文
如何通过宏来判断处理器类型(How to detect the processor type using compiler predefined macros)
1、ItaniumA.K.A.: IA64
Developer: Intel
Processors: Itanium, Itanium 2, Itanium 2 9000/9100/9300, etc.
代码:
#if defined(__ia64) || defined(__itanium__) || defined(_M_IA64)
/* Itanium ----...阅读全文
如何通过宏来判断操作系统的类型(How to detect the operating system type using compiler predefined macros)
1、AIXDeveloper: IBM
Distributions: AIX
Processors: POWER代码:
#if defined(_AIX)
/* IBM AIX. ------------------------------------------------- */
#endif2、BSDDeveloper: Open source
Dist...阅读全文
如何通过宏来检查编译器名称和版本信息(How to detect the compiler name and version using compiler predefined macros)
1、如何检查编译器名称
代码:
#if defined(__clang__)
/* Clang/LLVM. ---------------------------------------------- */
#elif defined(__ICC) || defined(__INTEL_COMPILER)
/* Intel ICC/ICPC. ------------------------...阅读全文
如何查看编译器的宏(How to list compiler predefined macros)
大多数编译器都有命令行选项来列出所支持的宏注:在某些开源的编译器源码中也可以找到支持的宏如:Clang 、LLVM中宏主要定义文件为llvm/tools/clang/lib/Basic/Targets.cpp
GCC 、 G++中宏主要定义文件为gcc/config/*
题外小知识:linux中有一个strings命令可以以二进制形式查看文本或者程序中的可打印字符串,对与编译器而言,这些串包...阅读全文
ANSI属性控制码(linux彩色终端打印支持)
#ifndef COLOR_H #define COLOR_H#define COLORCLOSE "033[0m" /关闭所有属性/ #define HIGHTCOLOR "033[1m" /设置高亮度/ #define UNDERLINE "033[4m" /下划线/ #define BLINK "033...阅读全文
日历
一 | 二 | 三 | 四 | 五 | 六 | 日 |
---|---|---|---|---|---|---|
  |   |   |   |   | 1 | 2 |
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
31 |   |   |   |   |   |   |