private void button1_Click(object sender, EventArgs e) { int nCnt = 0; List nNumList = new List(); for (int i = 0; i < cblNumList.Items.Count; i++) { if (cblNumList.GetItemChecked(i)) { nNumList.Add(Convert.ToInt32(cblNumList.Items[i].ToString())); }
D. Black Hills golden jewels time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output In Rapid City are located the main producers of the Black Hills gold jewelry, a very popular product among tour
题目一(输出国际象棋棋盘) 分析: 用i控制行,j来控制列,根据i+j的和的变化来控制输出黑方格,还是白方格. 主要代码: for i in range(8): for j in range(8): if (i+j)%2!=0: print(chr(219)*2,end='') else: print(' ',end='') print('') 题目二(排列组合问题) 有1.2.3.4个数字,能组成多少个互不相同且无重复数字的四位数?都是多少? 分析: 我们可以先预测一下,共有2
题目:编程求解,输入两个整数n和m,从数列1,2,3,……n中随意取几个数,使其和等于m.要求将所有的可能组合列出来. 分析:分治的思想.可以把问题(m,n)拆分(m - n, n -1)和(m, n - 1). 注意点:1.n大于m时,可直接从n = m出开始搜索 2.结束条件:n < 1 || m < 1 3.打印输出结果.注意打印输出结果并不代表函数调用结束,以n = 7 和 m = 10为例,7.3和7.2.1都是一种结果,不能得到7.3的时候终止.打印输出的条件是n = m 程序代码
//从数列1,2,3.......n 中 随意取几个数,使其和等于 m public static void Print(int n, int m, List<int> list = null) { if (n < 1 || m < 1) { return; } for (int i = 1; i <= n; i++) {
https://codeforces.com/contest/1236/problem/B Alice got many presents these days. So she decided to pack them into boxes and send them to her friends. There are nn kinds of presents. Presents of one kind are identical (i.e. there is no way to disting