using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;namespace Print{ public partial class Print : Form { public Print() {
其實就是屬性。屬性可以使外部程式能夠訪問你的私人欄位(前提是你的屬性是公有的)。但是屬性最大的作用是,可以在get和set裡面對欄位進行一些處理,包括判斷範圍,求值等處理。這樣一來是保證了資料的正確性,而來是保證你在外面讀取的時候欄位的值都是正確,而且是及時的資料。或者可以說 屬性最重要的作用是,做唯讀屬性,或唯寫屬性。這個是最有用的。控制了欄位的讀和寫,保證了程式的正確性。比如說:private int ss;public int SS{ get {return ss; }
using System;using System.Collections.Generic;using System.Text;namespace ConsoleApplication9{ class Program { static void sort(int[] arr) { int temp; for (int i = 0; i < arr.Length-1; i++) {
for(iterator it = begin(); it != end(); ++it) 此處的 begin()《==》this->begin() 或者for(iterator it = begin(); it != end(); it++) 區別是什麼呢?? 對於兩種方式來說:for(iterator it = begin(); it != end(); ++it){ return it->second;}for(iterator
題目連結 給出一個非減序的數組a[n], 然後得到s=2^a1+.……+2^an, 要使s為2^v -1,需要在數組中添加幾個數。 我的思路是這樣的,由2^a+2^a = 2^(a+1)可知,如果有兩個連續的數a,我們可以把他們合并為a+1放入集合中,使集合中沒有重複的數,我可以用stl裡的set。如果想要滿足題目中的要求,集合中必須有最大那個數個元素,缺多少就可以計算出來了。代碼://codeforces 305 C. Ivan and Powers of Two//201
A.Ilya and Bank AccountIlya得到了一個禮物,可以在刪掉銀行賬戶最後和倒數第二位的數字(賬戶有可能是負的),也可以不做任何處理。//codeforces 313A //2013-05-31-13.47#include <stdio.h>#include <algorithm>using namespace std;int main(){ int n; scanf("%d", &n); if (n) {