Time of Update: 2015-05-12
標籤:noip acm c++ oier P1097合并果子Accepted標籤:貪心NOIP提高組2004描述在一個果園裡,多多已經將所有的果子打了下來,而且按果子的不同種類分成了不同的堆。多多決定把所有的果子合成一堆。 每一次合并,多多可以把兩堆果子合并到一起,消耗的體力等於兩堆果子的重量之和。可以看出,所有的果子經過n-1次合并之後,就只剩下一堆
Time of Update: 2015-05-12
標籤:#include <iostream>using namespace std;#define N 100int A[N]; static int n; void Initial(){ cout << "請輸入元素的個數:"; cin >> n; cout << "請輸入" << n << "個元素:"; for(int i = 1; i <=n; i ++) {
Time of Update: 2015-05-12
標籤:// 期望輸出str = hello world 的兩種方法#include <stdio.h>char *GetStr(char **p){*p = "hello word";return *p;}int main(){char *str = NULL;if (NULL != GetStr(&str)){printf(" str = %s\n",str);}return 0;}</pre><pre name=
Time of Update: 2015-05-12
標籤:c語言 編程 遞迴 函數 參數 理解: 想用好函數應該對函數有一個充分的理解,如果不能充分理解函數,運用起來也會容易產生問題。關於函數的理解大家可以參考這篇部落格:函數再理解!。下邊就在下邊在運用上做一些相關說明。參數: 參數傳遞:
Time of Update: 2015-05-12
標籤:c++ 物件導向 開發模式 設計模式 面板模式 面板模式(Facade):為子系統中的一組介面提供一個一致的介面,此模式定義了一個高層介面,時刻這一子系統更加容易使用。使用情境:首先,在設計初期階段,應該要有意識的將不同的兩個層分離。比如經典的三層結構,就需要考慮在資料訪問層和商務邏輯層、商務邏輯層和展示層的層與層之間建立
Time of Update: 2015-05-12
標籤:(1)先看一個求平均值的函數#include <stdio.h>double average(int val,int v1,int v2,int v3,int v4,int v5){ double sum = v1; if(val >= 2) sum += v2; if(val >= 3) sum += v3; if(val >= 4) sum += v4; if(val >= 5)
Time of Update: 2015-05-12
標籤:c語言 可變參數列表 函數的調用 if C函數要在程式中用到以下這些宏:void va_start( va_list arg_ptr, prev_param );type va_arg( va_list arg_ptr, type );void va_end( va_list arg_ptr
Time of Update: 2015-05-12
標籤:習題9.39: 已知有如下string對象:string line1 = "We were her pride of 10 she named us:";string line2 = "Benjamin, Phoenix, the Prodigal";string line3 = "and perspicacious perspicacious pacific Suzanne";string sentence = line1 + ‘ ‘ + line2 + ‘ ‘ +
Time of Update: 2015-05-12
標籤:json c++ C++解析JSON(jsonCpp)JSON(JavaScript Object Notation) 是一種輕量級的資料交換格式。它基於JavaScript(Standard ECMA-262 3rd Edition - December 1999)的一個子集。 JSON採用完全獨立於語言的文字格式設定,但是也使用了類似於C語言家族的習慣(包括C, C++, C#, Java, JavaScript,
Time of Update: 2015-05-12
標籤:typedef struct struct typedef struct LNode{ int value; struct LNode *next}LNode,*LinkLIst;//此處可注釋通過typedef 我們可以知道: Lnode 是struct LNode的別名 LinkList 是 struct LNode * 的別名在不定義別名的時候,即注釋掉那行。struct test{int
Time of Update: 2015-05-12
標籤: 1 #include<iostream> 2 using namespace std; 3 4 int main() { 5 int a[10]; 6 int min=0, max=0; 7 cout << "Please enter 10 integer:" << endl; 8 for(int i=0; i<10; i++) 9 {10 cin >> a[i];11
Time of Update: 2015-05-12
標籤:1. 標準C語言C語言誕生於20世紀70年代,年齡比我們自己還要大,期間產生了很多標準,但是各種編譯器對標準的支援不盡相同。ANSI C是使用的最廣泛的一個標準,也是第一個正式標準,被稱為“標準C語言”。ANSI C於1980年由美國國家標準局(American National Standards Institute,簡稱ANSI)對外發布,各種編譯器幾乎都完整支援ANSI C,市面上的書籍、大學裡的教材、網上的教程大都以ANSI
Time of Update: 2015-05-12
標籤:c c++ java python leetcode Problem:Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of
Time of Update: 2015-05-12
標籤:1 /* 第一個C語言程式2 列印 Hello, world */3 #include<stdio.h> //包含標頭檔stdio.h4 int main(){ // 主函數5 printf("Hello, word\n"); // 列印字串6 return 0; // 返回0,表示程式正確運行7
Time of Update: 2015-05-12
標籤:#include <iostream>#include <vector>#include <pthread.h>#include "destory_free_while.h"using namespace std;Worker::Worker() { shutdown = false; num_thread = 10;}void Worker::start() { tids.resize(num_thread); for
Time of Update: 2015-05-12
標籤:一個C語言來源程式可以由一個或多個源檔案組成。每個源檔案可由一個或多個函數組成。一個來源程式不論由多少個檔案組成,都有一個且只能有一個main函數,即主函數。來源程式中可以有預先處理命令(include
Time of Update: 2015-05-12
標籤:using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace ConsoleApplication1{ class Program { static void Main(string[] args) { GenericArray<int> intArray = new
Time of Update: 2015-05-12
標籤:c#using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace ConsoleApplication1{ class Program{ &
Time of Update: 2015-05-12
標籤:好幾年沒寫過控制台程式了(上一次是大二時寫座標轉換時用過),因為我覺得使用者難以接受沒有良好操作介面的應用程式,我不想偷懶,今天來將應用程式改寫為控制台程式,記錄一下,忘記的內容:1.資料的互動不管什麼程式,都應該有資料的互動,使用者的輸入、程式的輸出。輸入:Console.ReadLine();[單個字元用:Console.Read();]輸出:
Time of Update: 2015-05-12
標籤:下面我們就動手來建立一個線程,使用Thread類建立線程時,只需提供線程入口即可。(線程入口使程式知道該讓這個線程幹什麼事)在C#中,線程入口是通過ThreadStart代理(delegate)來提供的,你可以把ThreadStart理解為一個函數指標,指向線程要執行的函數,當調用Thread.Start()方法後,線程就開始執行ThreadStart所代表或者說指向的函數。程式碼範例:using System;using System.Threading; namespace