宋凯鹏的个人网站
freopen("in.txt", "r", stdin); freopen("in.txt", "w", stdout);
#include <bits/stdc++.h> #include <ctime> using namespace std; clock_t start,stop; double duration; int main(int argc, const char * argv[]) { start = clock(); //my。
(1) 初始化两个栈:运算符栈S1和储存中间结果的栈S2;(2) 从左至右扫描中缀表达式;(3) 遇到操作数时,将其压入S2;(4) 遇到运算符时,比较其与S1栈顶运算符的优先级:(4-1) 如果S1为空,或栈顶运算符为左括号“(”,则直接将此运算符入栈;(4-2) 否则,若优先级比栈顶运算符的 高 ,也将运算符 压入 S1(注意转换为前缀表达式时是优先级较高或相同,而这里则不包括相同的情况);。
#include <iostream> #include <cstdlib> #include <ctime> using namespace std; typedef struct Node{ int Value; struct Node* Left; struct Node* Right; }Node,*Tree; Tree 。
#include <stdio.h> #include <stdlib.h> #include <iostream> #define LEN 11 using namespace std; typedef struct Heap{ int len; int* base; }Heap; void swap(int* a , int* 。
#include <bits/stdc++.h> using namespace std; class Complex{ private: double real; double imag; public: Complex(); Complex(double real); Complex。
以下是一个思考题,n=?#include <stdio.h> int main() { int n = 10; n = n++; printf("%d",n); return 0; }看到这个代码,大部分人可能与我一样,马上出来答案11。可惜,11是错的。我为了搞懂这么神奇的现象,特地把这段代码生成了汇编代码,结果如下: su。
用“埃氏筛法”求2~100以内的素数。2~100以内的数,先去掉2的倍数,再去掉3的倍数,再去掉5的倍数,……依此类推,最后剩下的就是素数。#include <stdio.h> int main() { int n[101]; for (int i =2 ;i <=100;i++){ n[i]=1; } 。
#include <stdio.h> #include <stdlib.h> #include <time.h> void swap(int* a,int* b) { int temp = *a; *a = *b; *b = temp; } int arr[10]; int main() { srand((unsigned。
#include <iostream> #include <cstdlib> using namespace std; typedef struct{ int* base; int len; }List; void init(List* list,int len) { list->base=(int*) malloc(sizeof(in。
void TestEmailIntegrity() { string eml; cin>>eml; int AtPos=(int)eml.find("@"); int DotPos=(int)eml.find("."); int rDotPos=(int)eml.rfind(".&qu。
#include <stdio.h> #include <stdlib.h> typedef struct Lnode{ int data; struct Lnode* Next; }Lnode,*List; List init(int schema) { List h=(Lnode*)malloc(sizeof(Lnode)); h-。
编译器 gcc,vc++使用的编译器,clang 经过测试,默认字节对齐方式均为8字节代码#include <iostream> using namespace std; #pragma pack (8) struct v1{ int a; long long b; char c; }; #pragma pack (4) struct。
#include <stdio.h> #include <stdlib.h> #include <string.h> void BucketSort(int *arr,int len,int max) { int *bucket; int i; int cnt=0; bucket=(int*)malloc(sizeof(int。
#include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct stack{ int *base; int top; int max; }stack; void InitStack(stack *s,int size) { s->bas。
#include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct stack{ char *base; int top; int max; }stack; void InitStack(stack *s,int size) { s->ba。
以下代码为测试执行时间的一个模板,仅供参考。#include <stdio.h> #include <time.h> #define COUNT_NUM 1000000//这里是重复执行次数 clock_t start,stop; int main(int argc, const char * argv[]) { //这里把预先执行的定义执行完毕 s。
#include <stdio.h> typedef struct{ unsigned int flag1 :3; unsigned int flag2 :2; unsigned int trailing : 27; }A; void showbin(unsigned int num) { unsigned int mask = 1u <<。
#include <iostream> using namespace std; int add(int a,int b) { int sum = a ^ b; int carray = (a & b) << 1; while(carray != 0) { int a = sum; int b = c。
#include <bits/stdc++.h> using namespace std; double x,y; double r,theta; void calc(int i); int main(int argc, const char * argv[]) { int code; while(1) { cout<<"。
#include <stdio.h> int gcd(int a,int b){ return b? gcd(b,a%b):a; } int lcm(int a,int b){ return a*b/gcd(a,b); } int main() { int a=3,b=4; printf("%d",lcm(a,b)); re。
scanf 的返回值有三种情况1.返回值为正数:返回传入值的个数2.返回值为0:输入格式有误3.返回值为-1:无输入同时 ~-1=0,~其他任何内容都为1所以scanf有一种常见的使用方法:while(~scanf("%d",&a))
#include <iostream> #include <cstring> #include <cstdlib> using namespace std; class Person{ protected: int No; char Name[20]; public: void input(); void show(); };。
#include <bits/stdc++.h> using namespace std; struct point{ int x,y; bool operator<(const point &r) const { if(x==r.x) return y<r.y; else 。
vector 需要头文件vector#include <bits/stdc++.h> using namespace std; int main(int argc, const char * argv[]) { vector<vector<int> > res; for(int i=0;i<9;i++) res.push_。
int i=0,j=0; while(1) { ch=getchar(); if(ch=='\n') break; if(ch==' ') { j++; i=0; continue; } word[。
#include <stdio.h> #include <stdlib.h> typedef struct{ int *plist; int size; int len; }list; void InitList(list *l,int size); void Distroy(list *l); void ClearList(list *l);。
#include <stdio.h> #include <stdlib.h> typedef struct { char *pBuffer; int Size; int Top; }stack; void MyStack(stack *p,int size); void DestroyStack(stack *p); int StackEmpty(。
#include "stdlib.h" typedef struct { int *pQueue; int QueueLen; int QueueHead; int QueueTail; int QueueCapative; }Queue; void InitQueue(Queue *Q,int Capative); void De。
#include <stdio.h> #include <stdlib.h> typedef struct{ int *pTree; int size; }tree; void Tree(tree *t,int *pRoot,int size); void Distroy(tree *t); int * SearchNode(tree *t,int nod。
头文件 #include <string.h>#include <stdio.h> #include <string.h> int main() { char str[]="I suppose i am very happy."; char * first_a = strchr(str,'a'); char * la。
头文件 #include <string.h>#include <stdio.h> #include <string.h> typedef struct{ size_t x; size_t y; }place; int main() { place a={1,2}; place b; memcpy(&b,&。
/*!< Signed integer types */ typedef signed char int8_t; typedef signed short int16_t; typedef signed long int32_t; /*!< Unsigned integer types */ typedef unsigned char 。
#include <stdio.h> void quicksort (int arr[],int L,int R,int Direction); int arr[]={4,2,9,8,5,6,1,3,7,3}; int main(int argc, const char * argv[]) { int i; int len=(int)sizeof(arr)/siz。
大写字母‘A’的ASCII的十进制代码为:65二进制代码为:1000001小写字母‘a’的ASCII的十进制代码为:97二进制代码为:1100001数字字符‘0’的ASCII的十进制代码为:48二进制代码为:0110001空格字符‘ ’的ASCII的十进制代码为:32二进制代码为:0100000专用字符‘%’的ASCII的十进制代码为:37二进制代码为:0100101转义字符‘n’的ASCII的。
1.先输入一个常用的头文件 例如:iostream2.按住command 点iostream3.点jump to difinition4.右击上面的iostream5.点v16.新建文件夹bits7.进入bits新建文件stdc++.h然后把下面代码输入进去即可// C++ includes used for precompiling -*- C++ -*- // Copyright (C) 。
#include <stdio.h>int a[1000][1000];int b[1000][1000];int c[1000][1000]={0};int main(int argc, const char * argv[]) {int x1,y1; int x2,y2; int i,j,k; scanf("%d%d",&x1,&y1); f。
#include <stdio.h>#include <math.h>int main(int argc, const char * argv[]) {char m[11]="10X98765432"; int z[18]={7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2}; char idcard[18]; int birth。
#include <stdio.h>int main(int argc, const char * argv[]) {int a=4; int b=9; int t; int c=a*b; if(a<b) { t=a; a=b; b=t; } while(b!=0) { t=a%b; a=b; b=t; }//此时,a为最小公因数。
#include <stdio.h>#include <math.h>int main(int argc, const char * argv[]) {double a,b,c; a=3;b=4; c=hypot(a,b); printf("c=%lf\n",c); return 0;}
注意:此头文件仅限Linux相关的系统使用#include "stdio.h"#include "stdlib.h"#include "pthread.h"void* myfuc(void* args){int i; for(i=0;i<50;i++) { printf("%d\n",i); } ret。
#include <stdio.h>#define R 3#define C 4int main(int argc, const char * argv[]){int a[R][C]={ {1,2,3,4}, {5,6,7,8}, {9,10,11,12}, }; int b[C][R]; int i,j; printf("a为:\n");。
#include <stdio.h>int *SelectSort(int *,int,int);int *BubbleSort(int *,int,int);int main(int argc, const char * argv[]) {int num[]={4217,3425,3245665,2435324,324534,3425,237,345756}; int i; int。
#include <stdio.h>#include <string.h>char* unit(int);int main(int argc, const char * argv[]){long long num; int nums[15]; char upper[10][4]={"零","壹","贰",&q。
#include <stdio.h>#include <math.h>int main(int argc, const char * argv[]) {int a,b,c; float delta; float x1,x2; int r; printf("\t\t二次函数计算器\n\n"); for (int i=1;i<100;i++) {。
#include "stdio.h"int main(int argc,const char *argv[]){ for(int i=0;i<argc;i++) { printf("%s\n",argv[i]); } return 0;}
函数名: sleep 头文件:#include <windows.h> // 在VC中使用带上头文件 #include <unistd.h> // 在gcc编译器中,使用的头文件因gcc版本的不同而不同 功 能: 执行挂起指定的秒数函数名: usleep 头文件: #include <unistd.h> 功 能: usleep功能把进程挂起一段时间, 单。
#include "stdio.h"#include "math.h"#define r 32#define x 66#define y 66int main(){char p[x][y]; int i=-1,j=-1; for (i=0;i<x;i++) { for(j=0;j<y;j++) { if ( 。