原创 Random_Select

#include "stdafx.h" int PARTITION(int a[], int p, int r) //以遞增順序排序 {

原创 1017.A除以B

#include <iostream> #include <string> using namespace std; int main() { string a; int b; cin >> a >> b; in

原创 1002.寫出這個數

#include "stdafx.h" string num_table[] = { "ling", "yi", "er", "san", "si", "wu", "liu", "qi", "ba", "jiu" };

原创 1005.繼續(3n+1)猜想

int count(int n, vector<int> &keys) { if (n == 1) { return 1; } else if (n % 2) {

原创 1001.3n+1猜想

#include "stdafx.h" int count(int n) { static int cnt = 0; if (n==1) { return cnt; }

原创 1007.素數對猜想

bool sushu(int n) { for (int i = 2; i <= sqrt(n);++i) { if (!(n%i)) { return 0

原创 1009.說反話

添加進vector的步驟有疑問,按我原有時機添加會丟掉最後的string,但是放在for循環外添加就不會丟掉。暫時沒有想到是什麼原因。 int _tmain(int argc, _TCHAR* argv[]) { ve

原创 Random_QuickSort

#include "stdafx.h" int PARTITION(int a[], int p, int r) //以遞增順序排序 {

原创 1012.數字分類

int _tmain(int argc, _TCHAR* argv[]) { int n; cin >> n; int *num = new int[n]; vector<int> A1, A2,

原创 1015.德才論

#include <iostream> #include <vector> #include <algorithm> #include <stdio.h> using namespace std; struct student

原创 1013.數素數

#include <iostream> #include <vector> #include <math.h> using namespace std; bool sushu(int n) { for (int i =

原创 1014.福爾摩斯的約會

#include <iostream> #include <string> using namespace std; int _tmain(int argc, _TCHAR* argv[]) { string s1, s

原创 1010.一元多項式求導

int _tmain(int argc, _TCHAR* argv[]) { vector<int> num; vector<int> index; int c; //char n; in

原创 同時得到最大最小值的最優算法

首先,我們將一對輸入元素進行比較,然後把較小的值與最小值比較,較大值與最大值比較。這樣,每兩個元素共需3次比較。 如果n是奇數,就把最大最小值的初值都設爲第一個元素的值,然後成對處理剩下的元素;如果n是偶數,則先比較前兩個元素,決

原创 1011.A+B和C

int _tmain(int argc, _TCHAR* argv[]) { int n; cin >> n; double **num = new double*[n];