随笔分类 - 算法分析
摘要:1 public class EFDbContext : DbContext2 {3 protected override void OnModelCreating(System.Data.Entity.DbModelBuilder modelBuilder)4 {5 modelBuilder.Entity<Class>().Property(object => object.property).HasPrecision(12, 10);6 7 base.OnModelCreating(modelBuilder);8 }9 }1 public De...
阅读全文
摘要:1 #include <iostream> 2 #include <vector> 3 using namespace std; 4 5 int _tmain(int argc, _TCHAR* argv[]) 6 { 7 int len; 8 cin>>len; 9 vector<int> array(len);10 for(int j=0;j<len;j++)11 {12 cin>>array[j];13 }14 int s=0;15 for(int i=0;i<len;i++)16 ...
阅读全文
摘要:1 #include "stdafx.h" 2 #include <iostream> 3 #include <vector> 4 using namespace std; 5 6 int _tmain(int argc, _TCHAR* argv[]) 7 { 8 int times; 9 cin>>times;10 for(int i=0;i<times;i++)11 {12 int len;13 int command;14 cin>>len>>command;15 vector<int>.
阅读全文
摘要:#include "stdafx.h"#include <iostream>using namespace std;void _tmain(int argc, _TCHAR* argv[]){ int temp[10]; for(int i=0;i<10;i++) { cin>>temp[i]; int k=i; int key=temp[k]; while(k>0&&temp[k-1]<key) { temp[k]=temp[k-1]; temp...
阅读全文
摘要:什么是子程序?子程序是为实现一个特定的目的而编写的一个可以被调用的方法或过程。比如:JAVA中的方法。什么是高质量?高质量是没有滥用子程序,在创建子程序的时候,满足各种各样的规范特征,具备各种各样的优点的子程序成为高质量的子程序一、创建子程序的正当理由降低复杂度:通过子程序可以帮助开发者隐藏一些信息,这样就不用开发人员考虑被隐藏部分的具体逻辑数据了。引入中间、易懂的抽象:在隐藏信息的同时,给子程序一个通俗易懂的名称,那么对于代码阅读方面有很大帮助。避免代码重复:子程序通过代表着一个功能,一个算法。它通常会在很多地方调用。子程序使得其内部的代码无需重复的编写,出现在整个代码的不同地方。支持子类化
阅读全文
摘要:求解数字二进制表示中1的个数?代码如下:class Program { private int Get(int number) { if (number == 0) return 0; if (number == 1) return 1; return number % 2 + Get(number / 2); } static void Main(string[] args) { int n=0; n = Console.Read(); n = (new Program()).Get(n); Console.Write(n); Console.ReadKey(); } } 这个程序的递归实现
阅读全文

浙公网安备 33010602011771号