自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(71)
  • 问答 (1)
  • 收藏
  • 关注

原创 C语言Matrix编程题——[Recursion]D. Liang 8.7 Fibonacci series

[Recursion]D. Liang 8.7 Fibonacci seriesDescription:计算斐波那契数列的函数被调用了多少次使用以下函数头int fibonacci(int index)Input:正整数n(n<=40)Output:输出fibonacci(n)Sample Input:10Sample Output:177Hint:Don’t submit the main() function.Programme://Date:2020/6/12/

2020-06-12 19:19:52 628

原创 C语言Matrix编程题——[Recursion]D. Liang 8.6 Summing series

[Recursion]D. Liang 8.6 Summing seriesDescription:用递归函数计算以下等式m(i) = 1/2 + 2/3 + … + i/(i+1)使用以下函数头double m(int i)Input:正整数n(n<=100)Output:输出m(n),结果保留两位小数Sample Input:1Sample Output:0.50Hint:Don’t submit the main() function.Programme://D

2020-06-12 18:49:54 398

原创 C语言Matrix编程题——[Recursion]D. Liang 8.5 Summing series

[Recursion]D. Liang 8.5 Summing seriesDescription:用递归函数计算以下等式m(i) = 1/3 + 2/5 + 3/7 + 4/9 + 5/11 + 6/13 + … + i/(2i+1)使用以下函数头double m(int i)Input:正整数n(n<=100)Output :输出m(n),结果保留两位小数Sample Input:1Sample Output:0.33Hint:Don’t submit the main

2020-06-12 18:06:16 847

原创 C语言Matrix编程题——[Recursion]D. Liang 8.4 Summing series

[Recursion]D. Liang 8.4 Summing seriesDescription:用递归函数计算以下等式m(i) = 1 + 1/2 + 1/3 + … + 1/i使用以下函数头double m(int i)Input:正整数n(n<=100)Output:输出m(n),结果保留两位小数Sample Input:3Sample Output:1.83Hint:Don’t submit the main() function.Programme://D

2020-06-12 17:48:00 430

原创 考试酷解析——C4_Scope of a Variable

解析第二题:有没有和外部文件联系不影响输出 scopre rule,可以当作没有extern 变量。第三题:extern 后面仍然要接数据类型,所以这题会报错是因为没有声明array 的 type 。第四题:extern 的作用域是从声明到当前文件的末尾,而非这个工程的任何一个文件,extern是表示此变量或函数是在别处定义的。第五题://Comment on the output of this C code?#include <stdio.h>int m

2020-06-05 20:50:04 264

原创 考试酷解析——C3_External Variables

解析第一题:先输出x,在声明x,会导致compile time error,一定要先声明再使用变量。第二题:不赋值,则默认变量为0。第四题://What is the output of this C code?#include <stdio.h>int x = 5;void main(){int x = 3;printf("%d", x);{int x = 4;}printf("%d", x);}注意变量的作用域,int x=4在花括号中,则

2020-06-04 21:05:14 194

原创 考试酷解析——C2_Functions Returning Non-integers

解析第一题:sqrt()函数返回的是double值第二题:在函数定义的花括号最后加上分号是合法的,所以上述都是对的,选none of mentioned。第四题:可以多次转换数值的类型,但是函数是int类型的,所以返回的值也一定是int类型的。第五题:即使是赋值,也要执行一遍函数,执行一次printf输出hello,返回值则是printf的默认返回值(返回字符串长度),所以输出hello 5第六题:int *m()返回的是5的地址,k是指向p(即5的地址)的指针变量,

2020-06-03 21:57:16 217

原创 考试酷解析——C1_Basics of Functions

解析第三题://What is the output of this C code?#include <stdio.h>int main(){void foo();void f(){foo();}f();}void foo(){printf("2 ");}在不同的编译器上有不同的表现,有的会允许在主函数里直接声明定义其他函数,有的就不可以,所以选Depend on complier第四题://What is the output of t.

2020-06-03 21:14:36 253

原创 C语言Matrix编程题——[Recursion]D. Liang 8.3 Computing greatest common divisor using recursion

[Recursion]D. Liang 8.3 Computing greatest common divisor using recursionDescription:用以下的函数完成一个计算最大公约数的函数int gcd(int n, int m)Input:两个正整数n,m(n<=100000,m<=100000),用空格或回车隔开Output:输出n和m的最大公约数Sample Input:16 24Sample Output:8Hint:Don’t submi

2020-06-03 15:53:16 548

原创 C语言Matrix编程题——[Recursion]D. Liang 8.2 Fibonacci number

[Recursion]D. Liang 8.2 Fibonacci numberDescription:用以下的函数完成一个计算斐波那契数列的函数long fib(int n)Input:非负整数n(n<=40)Output:输出斐波那契数列的第n项fib(n)Sample Input:3Sample Output:2Hint:Don’t submit the main() function.Programme://Date:2020/6/3//Author:Kamen

2020-06-03 15:41:54 582

原创 C语言Matrix编程题——[Recursion]D. Liang 8.1 Computing factorials

[Recursion]D. Liang 8.1 Computing factorialsDescription:用以下的函数完成一个计算阶乘的函数long factorial(int n)Input:正整数n(n<=30)Output:输出n!Sample Input:3Sample Output:6Hint:Don’t submit the main() function.Programme:long factorial(int n){ int i; lo

2020-06-03 15:22:41 465

原创 C语言Matrix编程题——[Pointers and C-String]D. Liang 7.20 Common prefix

[Pointers and C-String]D. Liang 7.20 Common prefixDescription:Write a function that returns the common prefix of two strings. For example, the common prefix of “distance” and “disjoint” is “dis”. The header of the function is as follows:char* prefix(con

2020-06-03 15:05:45 471

原创 C语言Matrix编程题——[Pointers and C-String]D. Liang 7.19 Guessing the capitals

[Pointers and C-String]D. Liang 7.19 Guessing the capitalsDescription:There are 49 states and the corresponding capitals of USA:State, CapitalAlabama, MontgomeryAlaska, JuneauArizona, PhoenixArkansas, Little RockCalifornia, SacramentoColorado, Den

2020-06-03 14:31:59 714

原创 C语言Matrix编程题——[Pointers and C-String]D. Liang 7.18 Anagrams

[Pointers and C-String]D. Liang 7.18 AnagramsDescription:Write a function that checks whether two words are anagrams. Two words are anagrams if they contain the same letters in any order. For example, “silent” and “listen” are anagrams. The header of the

2020-05-18 22:37:37 630

原创 C语言Matrix编程题——[Pointers and C-String]D. Liang 7.17 Sorting characters in a string

[Pointers and C-String]D. Liang 7.17 Sorting characters in a stringDescription:Write a functions that sorts characters in a string using the following function header:char* sortString(const char * const s)你的实现必须能通过以下代码测试:char * str = "bca";char * s1

2020-05-18 22:28:30 843

原创 C语言Matrix编程题——[Pointers and C-String]D. Liang 7.16 Decimal to binary

[Pointers and C-String]D. Liang 7.16 Decimal to binaryDescription:Write functions that parse a decimal number into a binary number as a string. The function header are as follows://Date:2020/5/18//Author:Kamenrider Justicechar* convertDecimalToBinary

2020-05-18 22:10:58 917

原创 C语言Matrix编程题——[Pointers and C-String]D. Liang 7.15 Decimal to hex

[Pointers and C-String]D. Liang 7.15 Decimal to hexDescription:Write a function that parse a decimal number into a hex number as a string. The function header are as follows:char * convertDecimalToHex(int value)Hint:Don’t submit the main() function.P

2020-05-18 21:54:57 577

原创 C语言Matrix编程题——[Pointers and C-String]D. Liang 7.14 Binary to decimal

[Pointers and C-String]D. Liang 7.14 Binary to decimalDescription:Write a function that parses a binary number as a string into a decimal integer.The function header is as follows:int parseBinary(const char * const binaryString)For example, binaryStri

2020-05-18 20:42:00 783 2

原创 C语言Matrix编程题——[Pointers and C-String]D. Liang 7.13 Hex to decimal

[Pointers and C-String]D. Liang 7.13 Hex to decimalDescription:Write a function that parses a hex number as a string into a decimal integer.The function header is as follows:int parseHex(const char * const hexString) For example, hexString “A5” is 165

2020-05-18 20:05:30 708

原创 C语言Matrix编程题——[Pointers and C-String]D. Liang 7.12 Occurrences of each letter in a string

[Pointers and C-String]D. Liang 7.12 Occurrences of each letter in a stringDescription:Write a function that counts the occurrences of each letter in a string using the following header:int * countLetters(const char * const s)The function returns the c

2020-05-18 19:29:22 819

原创 C语言Matrix编程题——[Pointers and C-String]D. Liang 7.11 Counting the letters in a string

[Pointers and C-String]D. Liang 7.11 Counting the letters in a stringDescription:Write a function that counts the number of letters in the string using the following header:int countLetters(const char * const str);Hint:Don’t submit the main() function

2020-05-18 18:28:59 621

原创 C语言Matrix编程题——[Pointers and C-String]D. Liang 7.10 Occurrences of each digit in a string

[Pointers and C-String]D. Liang 7.10 Occurrences of each digit in a stringDescription:Write a function that counts the occurrences of each digit in a string using the following header:int * count(const char * const s);The function counts how many times

2020-05-18 16:16:55 854 7

原创 C语言Matrix编程题——[Pointers and C-String]D. Liang 7.9 Occurrences of a specified character

[Pointers and C-String]D. Liang 7.9 Occurrences of a specified characterDescription:Write a function that finds the number of occurences of a speified character in the string using the following header:int count(const char * const str, char ch)Hint:Do

2020-05-18 15:47:09 567

原创 C语言Matrix编程题——[Pointers and C-String]D. Liang 7.8 Checking substring

[Pointers and C-String]D. Liang 7.8 Checking substringDescription:Write a function to check whether string s1 is a substring of string s2. The function returns the first index in s2 if there is a match. Otherwise, return -1.The function header is:int i

2020-05-14 15:59:55 1124

原创 C语言Matrix编程题——[Pointers and C-String]D. Liang 7.7 Checking palindrome

[Pointers and C-String]D. Liang 7.7 Checking palindromeDescription:A string is a palindrome if it reads the same forward and backward. The word “mom,” “dad,” and “moon,” for example, are all palindromes.Write a function to check whether a string is a pa

2020-05-13 21:55:13 866

原创 C语言Matrix编程题——[Pointers and C-String]D. Liang 7.6 Sorting

[Pointers and C-String]D. Liang 7.6 SortingDescription:Implement a sort function that returns a new sorted array, ascending order. The function header is:int *sort(const int * const array, int size);Hint:Don’t submit the main() function.Programme://

2020-05-13 20:59:09 733 3

原创 C语言Matrix编程题——[Pointers and C-String]D. Liang 7.5 Finding the smallest element

[Pointers and C-String]D. Liang 7.5 Finding the smallest elementDescription:Write a function that returns the smallest element of an array with the following headers:int smallestElement(int * array...

2020-05-08 17:08:23 276

原创 C语言Matrix编程题——[Pointers and C-String]D. Liang 7.4 Averaging an array

[Pointers and C-String]D. Liang 7.4 Averaging an arrayDescription:Write two overloaded functions that returns the average of an array with the following headers:int average_int(int *array, int size...

2020-05-08 16:58:07 275 1

原创 C语言Matrix编程题——[Pointers and C-String]D. Liang 7.2 Printing distinct numbers

[Pointers and C-String]D. Liang 7.2 Printing distinct numbersDescription:Use pointers on array to write a program that reads in n integers and displays distinct numbers (ie., if a number appears mul...

2020-05-08 16:36:29 415

原创 C语言Matrix编程题——[Pointers and C-String]D. Liang 7.3 Increasing array size

[Pointers and C-String]D. Liang 7.3 Increasing array sizeDescription:Once an array is created, its size is fixed. Occasionally, you need to add more values to an array, but the array is full. In thi...

2020-05-08 16:23:55 345

原创 C语言Matrix编程题——[Arrays]D. Liang 6.29 sicily 1145 校门外的树

[Arrays]D. Liang 6.29 sicily 1145 校门外的树Description:某校大门外长度为L的马路上有一排树,每两棵相邻的树之间的间隔都是1米。我们可以把马路看成一个数轴,马路的一端在数轴0的位置,另一端在L的位置;数轴上的每个整数点,即0,1,2,……,L,都种有一棵树。由于马路上有一些区域要用来建地铁。这些区域用它们在数轴上的起始点和终止点表示。已知任一区域的...

2020-05-08 15:55:38 344

原创 C语言Matrix编程题——[Arrays]D. Liang 6.28 纸牌游戏

[Arrays]D. Liang 6.28 纸牌游戏Description:桌子上有一叠牌,从第一张牌(即位于顶面的牌)开始从上往下依次编号为1~n。当至少剩下两张牌时进行以下操作:把第一张牌扔掉,然后把新的第一张牌放到整叠牌的最后。输入n,输出每次扔掉的牌,以及最后剩下的牌。Input:第一行为一个整数t(0<t<20),表示测试用例个数。以下t行每行包含一个整数n(0&lt...

2020-05-07 22:33:50 475

原创 C语言Matrix编程题——[Pointers and C-String]D. Liang 7.1 Analyzing input

[Pointers and C-String]D. Liang 7.1 Analyzing inputDescription:Use pointers on array to write a program that reads n numbers, computes their average, and finds out how many numbers are above the ave...

2020-05-07 21:42:16 696

原创 C语言Matrix编程题——[Arrays]D. Liang 6.26 Least Common multiple (LCM)

[Arrays]D. Liang 6.26 Least Common multiple (LCM)Description:Write a program that reads in two integers and finds their least common multiple (LCM). The LCM of two numbers is the smallest number tha...

2020-05-07 21:08:41 353

原创 考试酷解析——B5_Break and Continue

解析不要偷懒,最好在草稿纸上稍微演算一下。

2020-05-05 21:18:47 268

原创 考试酷解析——B4_While Loops

解析注意一下do while最后的while后面有没有分号即可。

2020-05-05 21:12:27 150

原创 考试酷解析——B3_For Loops

解析第四题://What is the output of this C code?#include <stdio.h>int main(){short i;for (i = 1; i >= 0; i++)printf("%d\n", i);}在到达short的范围后,程序不会报错,而是会直接结束,即successfully terminated。...

2020-05-05 19:37:08 230

原创 考试酷解析——B2_Switch Statements

解析第五题://What is the output of this C code?#include <stdio.h>int main(){int a = 1, b = 1;switch (a){case a*b:printf("yes ");case a-b:printf("no\n");break;}}case后面跟的一定要是常量表达式,不...

2020-05-05 19:22:58 99

原创 考试酷解析——B1_If-then-else Statements

解析第五题://The output of the code below is#include <stdio.h>void main(){int x = 5;if (x < 1);printf("Hello");}注意这里的if(x<1)后面有分号,即代表这一语句结束,后面直接输出Hello。第六题://The output of th...

2020-05-05 19:08:44 232

原创 考试酷解析——A16_Sizeof

解析第一题:char只占一个字节,即1 byte。第二题:'a'在C语言中被看作是整型字符常量(int),占4个字节,C++中则是看成字符,占一个字节。第三题:sizeof 指针和sizeof(a)相等。第五题:sizeof也是一个运算符。第七题:sizeof返回一个unsigned int 类型的值。...

2020-05-04 20:22:04 189

空空如也

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

TA关注的人

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