標籤:c語言//// main.c// 指標和數組//// Created by 邱學偉 on 15/7/25.// Copyright (c) 2015年 邱學偉. All rights reserved.//#include <stdio.h>#define N 4//冒泡法用指標實現//輸入int *enterNumber();//排序void sortNumberAsc(int *ptr);//輸出void printNumber(int *ptr);int
標籤:c語言//// main.c// 指標和數組//// Created by 邱學偉 on 15/7/25.// Copyright (c) 2015年 邱學偉. All rights reserved.//#include <stdio.h>#define N 4//冒泡法用指標實現//輸入int *enterNumber();//排序void sortNumberAsc(int *ptr);//輸出void printNumber(int *ptr);int
標籤: 對於大數的操作,可能超出int,甚至long的表示範圍,對此,可以使用數組來儲存大數,下列代碼為求1000以內數的階乘的代碼,代碼如下:#include <stdio.h>#include<string.h>const int max=3000;int main(){ int f[3000];//存放最終的結果 int i,j,n,c,tem; memset(f,0,sizeof(f)); scanf("%d",&n);
標籤:c語言//// main.c// statisticsSpace//// Created by 邱學偉 on 15/7/25.// Copyright (c) 2015年 邱學偉. All rights reserved.//#include <stdio.h>#include "string.h"#define N 1000//尋找第二個字串是否存在於第一個字串中,若存在返回位置,否則返回NULLchar *strstr_m(char *str1,char *str2
標籤:原文:http://blog.csdn.net/xhz1234/article/details/6510568C++:建構函式和解構函式能否為虛函數?簡單回答是:建構函式不能為虛函數,而解構函式可以且常常是虛函數。(1) 建構函式不能為虛函數讓我們來看看大牛C++之父 Bjarne Stroustrup 在《The C++ Programming Language》裡是怎麼說的:To construct an object, a constructor needs the exact
標籤:背景:在輸出資料行表時,往往需要按照某一欄位進行分組,比如在輸出城市列表時,按照首字母進行分組,輸出學生列表時,按照年級進行分組,然後再對分組的結果按照其他的欄位進行排序。如存在以下STU學生類,代碼如下:1 public class STU2 {3 public int ID { get; set; }4 public string Name { get; set; }5 public int Age { get; set;
標籤:exercise 1-13/* Write a program to print a histogram of the lengths of words in its input. It is easy to draw the histogram with the bars horizontal; a vertical orientation is more challenging. */#include <stdio.h>#define MAXHIST 15
標籤:最大公約數和最小公倍數:PS:最小公倍數 = 乘積 / 最大公約數http://acm.swust.edu.cn/problem/0038/#include <stdio.h>int main(){ int m, n, i, c, t; //t為最大公約數, c為最小公倍數 scanf("%d%d", &m, &n); for (i = 1; i <= m&&i <= n; i++) { if (
標籤:exercise 1-14/* Write a program to print a histogram of the frequencies of different characters in its input. */#include <stdio.h>#include <ctype.h>#define MAXHIST 15 /* max length of histogram */#define MAXCHAR 128 /* max
標籤:exercise 1-15/* Rewrite the temperature conversion program of Section 1.2 to use a function for conversion. */#include <stdio.h>float celsius(float fahr);/* print Fahrenheit-Celsius table or fahr = 0, 20, ..., 300; floating-point version