自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(37)
  • 收藏
  • 关注

原创 Use bubble sort to sort the input intergers

Use bubble sort to sort the input intergers

2015-05-27 13:59:09 632

原创 Find all the narcissistic numbers from 100 to 999

In recreational number theory, a narcissistic number (also known as a pluperfect digital invariant (PPDI), an Armstrong number (after Michael F. Armstrong) or a plus perfect number) is a number that is

2015-05-24 10:13:02 1150

转载 C语言main()函数详解

Source: http://c.biancheng.net/cpp/html/725.htmlC的设计原则是把函数作为程序的构成模块。main()函数称之为主函数,一个C程序总是从main()函数开始执行的。 一、main()函数的形式在C99 标准中,只有以下两种定义方式是正确的:int main( void ) /* 无参数形式 */{ ... return 0;}i

2015-05-22 21:22:59 963

原创 Integer Factorization

Every positive integer larger than 1 can be uniquely factorized into a product of prime numbers. These prime numbers are called the prime factors. Find all the prime factors of an input integer.

2015-05-14 13:11:58 490

原创 Check an input positive interger is a prime number or not

/* To check an input positive interger is a prime number */#include<iostream>#include<cmath>using namespace std;bool isPrime(int);int main(){ int y; cout<<"Please input a positive interger."<<end

2015-05-13 14:25:13 618

转载 gcc 编译器对 sqrt 未定义的引用

编译的时候也要在指令后面加 -lm:      gcc -o abc abc.c -lm原因:缺少某个库,用 -l 参数将库加入。Linux的库命名是一致的, 一般为 libxxx.so, 或 libxxx.a, libxxx.la, 要链接某个库就用   -lxxx,去掉头 lib 及 "." 后面的 so, la, a 等即可。常见的库链

2014-10-03 09:48:22 1533

原创 Exchange the values of two variables without using an extra variable

Exchange the values of two variables without using an extra variable

2014-09-24 20:17:12 530

转载 ubuntu分区方案

新分区的类型:Primary(主分区)单独安装Ubuntu到全新磁盘,/分区需要选择Primary,其它分区选择Logical逻辑分区就可以;如果将/boot单独分区,则/boot为主分区,而/分区不必是主分区。文件类型,我是全部选择Ext4。各个分区配额(硬盘大小320G)1.swap 交互分区(在文件系统栏中选择swap),本分区一般分1G就足够

2014-08-25 20:50:32 862

原创 Count the digits of any input integers

Given an interger,1) Count its digits2) Output its eve

2014-08-08 20:41:40 523

原创 Print the isosceles triangle using symbol "*"

Key Points:1) Use double "for" cycle2) Calculate the number of spaces before symbol "*"

2014-08-06 18:53:17 678

原创 Reverse an input character string

//Inverse an input charater string#includeint main(){ char a[50]; int l; char *p; printf("Please input a character string:\n"); gets(a); l = strlen(a); for (p = &a[l-1]; p >= a; p--)

2014-07-26 15:51:08 625

转载 (Matlab) simulink和m文件的相互调用

m文件对simulink的连接:1、在m文件中首先打开mdl文件,用open_system('model');2、现在可以在m文件中用set_param()和get_param()函数改变和获得simulink中模块的参数值;把m函数封装成simulink模块(matlab7.0):1、可以应用user-Defined Functions 里面的Embedded MATLA

2014-07-24 19:25:38 49485 9

原创 Calculate the Greatest Commom Divisor (GCD) and Lowest Common Multiple (LCP) of Two Integers

以上方法是用更相减损法求最大公约数,所谓更相减损法,即“以少减多,更相减损,求其等也,以等数约之,等数约之,即除也,其所以相减者皆等数之重叠,故以等数约之”。

2014-07-18 14:37:44 827

原创 Check whether two input intergers are the same without using comparison operator

//Check wheter two input intergers are the same without using the #includeint main(){  int a,b;  printf("Please input two intergers:\n");  scanf("%d%d",&a,&b);  if ((a^b) == 0)   {

2014-07-18 09:26:19 632

转载 Interview Experience Sharing (Coding)

1.  http://blog.renren.com/share/202294330/11212742322过去的一年多里,参加了一些面试,虽然面过的公司不多,但都从头一直走到尾。毕竟自己也是花了大量的时间和精力在这一场场的面试里。所以,就絮叨下自己的一些经验,希望能给在美国找实习找工作的同学们提供一点点帮助。开始前的一些说明:1. 笔者

2014-07-17 14:36:30 671

原创 Enumeration (C)

#includeint main(){ enum season {spring, summer, autumn, winter} s; for(s = spring; s <= winter; s++) { printf("s is %d\n",s); //Enumeration element is regarded as interger constant. }

2014-07-17 11:12:54 496

原创 Structure (C)

1.#include//Define a structurestruct Student{ int age;};void test(struct Student stu){ printf("The former parameter before revision is: %d\n", stu.age); //Revise the formal paramet

2014-07-17 10:59:23 613

原创 Header Files Inclusion (C)

文件包含//第一种形式 #include ,直接到C语言库函数头文件所在的目录寻找文件//第二种形式 #include “文件名”  系统现在源程序当前目录下寻找,若找不到,再到操作系统的path路径中查找,最后才到C语言库函数头文件所在目录中查找//#include指令允许嵌套包含,比如a.h包含b.h, b.h包含c.h,但是不允许递归包含,比如a.h 包含b.h, b.h包含a.

2014-07-16 11:05:56 529

原创 Static Variable, Auto Variable, Global Variable, Local Variable, Register Variable (C)

变量的作用域:(1)局部变量: 即在函数内部定义的变量,形式参数也属于局部变量。局部变量只在定义它的函数内部有效。(2)全局变量: 即所有函数外部定义的变量,其作用范围是从定义变量的位置开始到源程序结束。 变量的存储类型:(1) 自动变量,存储在堆栈中,被关键字auto修饰的局部变量是自动变量,所有的局部变量在默认情况夏都是自动变量。生命周期:在程序执行到声明自动变量的代码块(

2014-07-16 10:27:35 1095

原创 Simple Exercises about Marco Definition (C)

1.//宏定义//带参数的宏定义,与函数很像,区别在于//(1)宏定义不涉及存储空间的分配、参数类型匹配、参数传递、返回值问题//(2)函数调用在程序运行时执行,而同替换只在编译预处理阶段进行。所以带参数的宏比函数有更高的执行效率。#include#define D(a) 2*aint main(){ int b = D(3+4); printf("%d\n",b)

2014-07-16 10:14:43 576

原创 Character String and Character String Array in C Programming

1.#includeint main(){ char b[] = {'R','O','H','E','\0','O','O','\0'}; char a[3] = {'H','E','\0'}; //Remember to add '\0' as the end of a string printf("The string a is %s\n",a); puts(a); /

2014-07-15 12:05:53 826

原创 Pointer that points to function (C)

//指向函数的指针//定义的形式:函数的返回值类型(*指针变量名) (形式参数1,形式参数2,...);#includeint sum(int a, int b){ return a + b;}int main(){ //定义一个指针变量p,指向sum函数 int (*p) (int a, int b) = sum; //或者 int (*p)(int,

2014-07-15 10:24:21 504

原创 The function that returns the pointer (C Programming)

//返回指针的函数//输入字符串,并将其中的小写字母改为大写字母char *upper(char *str){ char *dest = str; while(*str != '\0') { if(*str >= 'a' && *str <= 'z') { *str -= 'a' - 'A'; } str++; }

2014-07-15 10:09:18 545

原创 Some Exercises about Pointer (C Programming)

1.#includeint main(){ int i = 3; char c = 4; int *p = &c; printf("*p is %d\n",*p); return 0;}2.#includeint main(){ int a[4] = {1,2,3,4}; int *p = a; int i; printf("Use poi

2014-07-15 09:53:42 421

转载 面向过程和面向对象的比较

Q:面向对象和面向过程的优缺点,结合实例进行阐述A:一、个人理解,面向对象相对于面向过程较显著的优势莫过于可扩展性、可维护性。众所周知在软件开发过程中,开发人员与客户需要不断的沟通,而客户的需求也往往在不断的变化,软件的功能也不是一成不变的。如果采用面向过程的方法来进行软件开发,当用户需求发生变化时,比如要求修改现有软件功能的实现方式或者要求追加新的功能时,就需要自顶向下地修改模块的结构,

2013-09-25 20:52:44 681

原创 Bubble Sort

// Bubble Sort#includeint main(void){ int a[10]; int i,j,t; printf("Pls input 10 numbers:\n"); for (i = 0; i < 10; i++) scanf("%d",&a[i]); printf("\n"); for (j = 0; j < 9; j++) { for (i

2013-09-25 19:17:39 443

原创 Find the sum of S = a + aa + aaa + aaaa + aaaaa +......+ aaa...aaa +...

// Find the sum of S = a + aa + aaa + aaaa + aaaaa +......+ aaa...aaa +...#include#includevoid main(){ int a, i, n; long s = 0, sum = 0; printf("Please input the value of a and n :\n"); scanf

2013-09-21 21:28:12 1300

原创 Two Methods of Finding the sum of 1! + 2! +3! + 4! +...+ 20!

My Method:  // Find the sum of 1! + 2! +3! + 4! +...+ 20!int term(int r){ int i; long t = 1; for (i = 1; i <= r; ++i) t = t * i; return t;}#includevoid main(){ int j, n = 20; long

2013-09-21 20:34:29 720 2

原创 Count the number of alphabets, spaces, digits and other characters in one line character

// Count the number of alphabets, spaces, digits and other characters in one line character#includevoid main(){ char c; int i = 0 ,j = 0, m = 0, n = 0; printf("Please input one line characters:

2013-09-21 17:05:12 1169

原创 Telegram Encoding and Decoding

// Telegram Encoding#includevoid main(){ char c; while((c = getchar()) != '\n') { if((c >= 'a' && c = 'A' && c <= 'Z')) { c = c + 4; if ((c > 'z') || (c < 'z' && c <= 'Z'-4)) c =

2013-09-18 17:28:51 783

转载 谈谈工科学生如何学习数学

谈谈工科学生如何学习数学                                                  邹谋炎                       (中国科学院研究生院暑期讲座材料) 不少工科学生特别是工科研究生对数学基础不足感到压力。确实,缺乏数学的帮助会使得学生们的研究缺乏思路和工具,缺乏捕捉问题的敏感性,缺乏抽取问题本质的能力,缺乏处理问题的技巧和

2013-09-18 15:12:18 1833

原创 为什么计算机网络要采用分层结构

为什么计算机网络要采用分层结构?1)各层之间相互独立:高层是不需要知道底层的功能是采取硬件技术来实现的,它只需要知道通过与底层的接口就可以获得所需要的服务; 2)灵活性好:各层都可以采用最适当的技术来实现,例如某一层的实现技术发生了变化,用硬件代替了软件,只要这一层的功能与接口保持不变,实现技术的变化都并不会对其他各层以及整个系统的工作产生影响; 3)易于实现和

2013-09-18 15:00:54 34282

原创 Two Minor Questions

Question 1:We would like to assign rooms for students. Assume there are x students,  each room could accommodate 6 students. Use one formula to find out how many rooms we needed in total.Ans

2013-09-17 22:35:41 641

原创 Find all the prime number between 1 and 100

/* Find all the prime number between 1 and 100 */#include#includeint main(){int i,n,j = 0;for (n = 2; n <= 100; ++n){bool isPrime = true;for (i = 2; i {if (n % i

2013-09-17 22:32:07 1199

原创 The Flow Chart of Running C Program

2013-09-17 22:28:46 694

原创 Calculate the area of dashed part

Answer: 5.5

2013-09-17 22:12:23 575

原创 Exchange the numbers of row and array of a two-dimensional array, and form a new two-dimensional ar

// Exchange the numbers of row and array of a two-dimensional array, and form a new two-dimensional array#includevoid main(){ int a[2][3]={{1,2,3},{4,5,6}}; int b[3][2],i,j; printf("arrary a:\n"

2013-09-17 21:16:47 749

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除