pku 1013 稱硬幣

#include <iostream>#include <string>using namespace std;string Left[3], Right[3], result[3];bool dealLight(char& ch){for(int i = 0; i < 3; ++i){switch(result[i][0]){//u -> up,d -> down,e -> evencase

pku 1953 World Cup Noise

#include <iostream>#include <fstream>using namespace std;#define MAX 46int Fibonacci[MAX];int main(){int N, n;int cnt = 0;Fibonacci[1] = 2;Fibonacci[2] = 3;for(int i = 3; i <= 45; ++i)Fibonacci[i] = Fibonacci[i-1] +

鏈表倒轉等操作完整程式

 寫一個鏈表的的操作的例子,雖然沒什麼難度,但是好久沒寫了,練練手。 #include<stdio.h>typedef struct tagLinkNode                                         //定義一個節點結構體...{    char m_type;    struct tagLinkNode *next;}LinkNode;LinkNode* CreatLinkList(int n)        //建立鏈表的函數...{    

指標傳遞記憶體深入探討(一)

林銳的《高品質C/C++程式設計指南》有這樣一個例子:void GetMemory(char *p, int num){ p = (char*)malloc(sizeof(char)*num);}int main(){ char *str = NULL; GetMemory(str, 100); strcpy(str, "hello"); }書中也說這樣用是完全錯誤的,但是錯誤的原因書中解釋的並不是很容易讓人理解為了便於大家理解我們可以用gcc這個工具來查看彙編代碼以下是GetMemory函數:

指標傳遞記憶體深入探討(二)

 我們繼續討論關於指標傳遞記憶體的問題《高品質C/C++程式設計指南》中這樣用是正確void GetMemory2(char **p, int num){ *p = (char*)malloc(sizeof(char)*num);}int main(){ char *str =NULL; GetMemory2(&str, 100); strcpy(str,

pku 1363 車站

#include <iostream>using namespace std;#define MAX 1005int map[MAX];int result[MAX];struct Stack{int stack[MAX];int index;Stack():index(0){}void push(int& v){stack[index++] = v;}int pop(){return stack[--index];}int top(){return stack[index-

指標傳遞記憶體深入探討(三)

 讓我們繼續前兩次的討論我們同樣可以使用把指標作為傳回值的方法來傳遞記憶體,而且我個人認為這是值得推薦的方式c代碼:char *GetMemory3(int num){ char *p = (char *)malloc(sizeof(char)*num); return p;}int main(){ char *str = NULL; str = GetMemory3(100); strcpy(str, "hello"); printf("%s",

pku 1166 暴力窮舉

#include <iostream>using namespace std;int map[9][9] = {{1,1,0,1,1,0,0,0,0},{1,1,1,0,0,0,0,0,0},{0,1,1,0,1,1,0,0,0},{1,0,0,1,0,0,1,0,0},{0,1,0,1,1,1,0,1,0},{0,0,1,0,0,1,0,0,1},{0,0,0,1,1,0,1,1,0},{0,0,0,0,0,0,1,1,1},{0,0,0,0,1,1,0,1,1}};int v[9

交換器 路由器 集線器的區別

最近看到很多人在詢問交換器、集線器、路由器是什麼,功能如何,有何區別,筆者就這些問題簡單的做些解答。首先說HUB,也就是 集線器 。它的作用可以簡單的理解為將一些機器串連起來組成一個區域網路。而 交換器 (又名交換式集線器)作用與集線器大體相同。但是兩者在效能上有區別:集線器採用的式共用頻寬的工作方式,而交換器是獨享頻寬。這樣在機器很多或資料量很大時,兩者將會有比較明顯的。而 路由器 與以上兩者有明顯區別,它的作用在於串連不同的網段並且找到網路中資料轉送最合適的路徑

pku 3126 bfs

#include <iostream>using namespace std;int n1, n2;bool map[10000];int value[10000];int q[11000];int c[4]= {1, 10, 100, 1000};bool bfs(){int front = 0, rear = 0;q[rear++] = n1;value[n1] = 0;while(front < rear){int temp = q[front++];if(temp ==

pku 2346 乘法原理

#include <iostream>#include <cmath>using namespace std;int hash[46];int main(){int n;scanf("%d", &n);__int64 sum;for(__int64 i = 0; i < (__int64)pow(10.0, n/2); ++i){sum = 0;__int64 p = 1;for(int j = 0; j < n/2; ++j){sum +=

pku 2453 超級位元運算

#include <iostream>using namespace std;int main(){int n, x;while(scanf("%d", &n) && n){x = n&-n; // 後面0的個數m的2^mprintf("%d/n", n+x + (n^(n+x))/x/4);// n+x 將從右往左第一個01變成10// (n^(n+x))/x/4 將剩下(除了變化的那兩位,故除4)的1移位}return 0;}

pku 1157 Litte Shop Of Flowers(商店的花的最大欣賞價值)

#include <iostream>#include <climits>using namespace std;#define MAXF 101#define MAXV 101int A[MAXF][MAXV];int f[MAXF][MAXV];int main(){int F, V;scanf("%d%d", &F, &V);for(int i = 1; i <= F; ++i)for(int j = 1; j <= V;

pku 1844 一道關於數學的水題

#include <iostream>using namespace std;int main(){int n;scanf("%d", &n);int i, sum = 0;bool OverFlag = false;for(i = 1;; i++){sum += i;if(sum == n){printf("%d/n", i);OverFlag = true;break;}else if(sum > n)break;}if(!OverFlag){while((sum

pku 2533 最長上升子序列

#include <iostream>using namespace std;#define MAX 1001int A[MAX];int L[MAX];int main(){int n, max;scanf("%d", &n);for(int i = 1; i <= n; ++i)scanf("%d", &A[i]);//dpL[1] = 1;for(int i = 1; i <= n-1; ++i){max = 1;for(int j = 1; j &

pku 2085 純粹找規律

//AC Code#include <iostream>#define Swap(x,y) {int temp = x;x = y;y = temp;}#define MAX 50001int map[MAX];bool hash[MAX];int main(){int i, j, k, n, v;while(scanf("%d%d", &n, &v) && n != -1){memset(hash, false, sizeof(bool)*(n+1)

pku 1664 分蘋果(整數劃分)

#include <iostream>using namespace std;int f(int m, int n){if(m < 0)return 0;if(m == 0 || n == 1)return 1;return f(m, n-1) + f(m-n, n);}int main(){int n;scanf("%d", &n);int M, N;while(n--){scanf("%d%d", &M, &N);printf("%d/n",

一個字串的操作可以求子串並定位

            隨便寫的一個字串的操作可以在一個子串中求出某一個子串的出現次數和出現的位置。 #include<iostream>#include<string>using namespace std;int  PartPostion(char src[], char partString[], int pos)                                                                             

pku 1222 熄燈

#include <iostream>using namespace std;int map[7][8];//5*6int result[7][8];int main(){int N;int cnt = 0;scanf("%d", &N);while(N--){memset(result, 0, 7*8*sizeof(int));for(int i = 1; i <= 5; ++i)for(int j = 1; j<= 6; ++j)scanf("%d",

由盧旺達的“高薪”想到的

          今天看見一個人發帖說什麼他看見報道說盧旺達話務中心的大學生每月正1000美金。他還憤憤不平的說在中國工資如何如何少,發泄心中的不滿情緒。        後來有一個網友回帖說他去過盧旺達,實事並非如此,本科生畢業工資能超過100美金就不錯,只有很少的管理員才能達到400美金。      

總頁數: 61357 1 .... 17902 17903 17904 17905 17906 .... 61357 Go to: 前往

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.