![](https://img-blog.csdnimg.cn/20200318083323787.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
C Programming
C
ROBIN.FANG
这个作者很懒,什么都没留下…
展开
-
环境变量的配置、JDK的下载安装、Eclipse安装 最新攻略总结
环境变量配置:右击电脑属性---->选择高级系统设置----->环境变量----->上面大方框中修改path或添加path路径,路径是jdk文件中bin文件的路径复制过来即可 添加 classpath变量名------->值是 .;lib和文件夹路径 添加 JAVA_HOME变量名------>值是 jdk的根目录路径复制过去即,添加JAVA_H...原创 2019-01-10 00:28:13 · 310 阅读 · 0 评论 -
Visual Studio Code 2020安装教程、CPP环境配置
1)下载,直接点下一步安装即可官网下载地址:https://code.visualstudio.com/2)安装cpptools工具3)下载MinGW下载地址:https://sourceforge.net/projects/mingw-w64/files/下载的文件:进入网站后不要点击"Download Lasted Version",往下滑,找到最新版...原创 2020-02-29 16:56:45 · 11101 阅读 · 5 评论 -
C语言-用三目运算实现十进制到二进制的转换
问题:Write a program that prints a table of the binary equivalentsof the decimal numbers in the range 0 through 15Use conditional operator ( ? : )#include<stdio.h>#include<stdlib....转载 2019-03-19 12:31:35 · 251 阅读 · 0 评论 -
C语言函数-求直角三角形的斜边hypotenuse
问题:Define a function 'hypotenuse' that calculates the length of the hypotenuse of a right triangle when the other two sides are given The function should take two argument of type double and return...原创 2019-03-26 21:55:40 · 9470 阅读 · 0 评论 -
C语言-Initialization of one-dimensional array
数组初始化:指定数组长度时,可以只给数组中部分元素赋初始值,其余未赋值元素自动为0int a[10]={1,4,6,8};不指明数组长度时,而由初始值元素个数决定数组的长度int a[]={1,4,8}; //数组的长度就是3#include<stdio.h>#include<stdlib.h>/*Compute the ...转载 2019-03-27 15:24:18 · 334 阅读 · 0 评论 -
C语言-找出数组元素中的最大值和最小值
#include<stdio.h>#include<stdlib.h>int main(void) { int a[5] = { 7,3,20,8,9 }; int max = a[0]; for (int i = 0; i < 5; i++) { if (a[i] > max) { max = a[i]; } } prin...转载 2019-03-27 15:53:29 · 70825 阅读 · 1 评论 -
C语言-二维数组的定义、引用
定义由行和列组成的二维表格形式元素,二维数组其实也就是矩阵基本格式:数据类型 数组名[行长度][列长度];行长度为二维数组行的个数,必须为常量表达式,不能为变量列长度为二维数组每一行列的个数,必须为常量表达式,不能为变量二维数组包含的元素的个数是:行长度*列长度,其中每个元素占据的字节数是sizeof(数据类型),故二维数组占据的内在字节数是 行长度*列长度*sizeof(数...转载 2019-04-10 19:05:52 · 15616 阅读 · 0 评论 -
C语言-查找一个元素是否在数组中(顺序查找、二分查找)
顺序查找:#include<stdio.h>#include<stdlib.h>#define LENGTH 5int main(void) { int a[LENGTH] = { 1,3,5,7,11 }; int x; printf("Please enter the number you want to find:"); scanf_s(...转载 2019-03-27 19:53:47 · 9781 阅读 · 0 评论 -
C语言-冒泡排序算法实现
冒泡排序:1. 可能需要进行多趟排序,最终才能实现有序2. 每一趟排序,需要依次比较两个元素的大小关系,满足条件再交换3. 当左侧元素大于右侧元素时,应该交换这两个元素4. 每一趟排序结束后,当前最大的元素会找到自己的固定位置(在最右侧)5. 每一趟处理的元素个数是递减的6. n个元素的冒泡排序需要n-1趟比如,排序 15, 37, 12, 9 ,4第一趟:比...原创 2019-03-28 23:45:47 · 282 阅读 · 0 评论 -
C语言-二维数组的初始化、输出、输入
方法1:分行初始化(全部初始化):int a[2][3]={ {1,2,3}, {4,5,6}};分行初始化(部分初始化):int a[2][3]={ {1,2}, {4}};方法2(不常用):按元素的顺序初始化(全部初始化):部分初始化(部分初始化):#include<...转载 2019-04-11 11:52:32 · 35333 阅读 · 2 评论 -
C语言函数-写一个能判断字母大小写的程序
问题:write a program that inputs a character and passes it to function 'ulcase',which uses the ASCII values to determine whether the given character is inuppercase or lowercaseThe function shoul...转载 2019-03-28 11:45:08 · 9075 阅读 · 0 评论 -
C语言-字符数组、输入、输出
字符数组的定义:一维字符数组: char 数组名[数组长度];char ch[10]; char name[20];二维字符数组:char 数组名[行长度][列长度]char names[50][20]; 字符数组在内存中所占的字节数: 数组长度 个字节字符数组的初始化:分别为字符数组的每个元素赋初始值,字符数组长度为字符个数...转载 2019-04-12 12:03:33 · 1970 阅读 · 1 评论 -
C语言-选择排序算法实现
选择排序:选择排序同样要经过多趟 每一趟找到当前元素中的最小(大)值,放到它应有位置,然后这个元素就固定了,也就是说下一趟排序不再考虑这个元素举个例子:4, 5,1, 3, 2第一趟:4和5比较,找到较小的是 4,把是拿出来。4和1比较,1<4, 所以 4和1 交换,得到顺序 5,4,3,2,然后把1拿出来1再分别和3,2比较都是小,所以把1是最下,然后放...原创 2019-04-09 21:12:37 · 455 阅读 · 3 评论 -
Visual Studio 解决同一个项目下运行多个小程序文件问题
问题:刚开始练习c++,一般都写一点简单的小程序,都有main函数,在同一个项目下不能运行,怎么做可以不用每次都创建新项目,在同一个项目下,分别运行简单的小程序(都含有main函数),还是每次都得创建新项目?比如运行输出“helloworld”和运行输出一个和运算。解答:方法一:因为已经规定一个程序只能有一个main函数,所以你想在不同的cpp中都写上m...转载 2019-04-09 18:41:03 · 9231 阅读 · 1 评论 -
C语言- 一维数组的定义及访问
C语言中的数组是可以批量管理多个连续数据的一种数据类型注意:数组也是一种数据类型比较正式的定义是:数组是具有一定顺序关系的若干相同类型数据集合一维数组的定义:基本格式:类型符 数组名[常量表达式]类型符:表示基本数据类型,如int, float,double,char..常量表达式:表示数组元素的个数,必须是整型数据常量表达式,不能是变量int a[5]; ...转载 2019-03-19 09:17:20 · 2789 阅读 · 0 评论 -
C语言-用for循环计算pi 的精确度
转载 2019-03-25 10:34:23 · 4227 阅读 · 0 评论 -
C语言-实现在线零售结账
问题:An online retailer sells five different products whose retail prices areshown in the following table:Write a program that reads a series of number: (1) Product numberand(2) Quantity sold,...转载 2019-03-21 17:41:56 · 915 阅读 · 0 评论 -
C 加、减、乘、除以及求余数
本节主要考察几个知识点:用C语言求实现数学求和 求乘积 差 商 求余数Problem: Write a program that asks the user to enter two numbers, obtains them from the user and prints their(1) sum, (2) product, (3) difference, (4) quo...原创 2018-12-01 20:59:01 · 1025 阅读 · 0 评论 -
C 判断两个数是否为倍数关系问题
问题:Write a program that reads two integers, and determines and prints if the first is a multiple of the second#include<stdio.h>#include<stdlib.h>int main(void) { int num1, num...原创 2018-12-29 15:51:44 · 4833 阅读 · 0 评论 -
C 求两个整数之间所有整数和问题
问题:Write a program that(1) inputs two integers (integer1 and integer 2)(2) prints sum of all integers between integer1 and integer2(3) Use while() statementEx) input : 10, 15 -> Sum : 10 ...原创 2018-12-29 16:19:48 · 4375 阅读 · 0 评论 -
C 求一个数的阶乘问题
问题Write a program that reads a nonnegative integer, and computes and prints its factorial(For example, 5! = 5x4x3x2x1 = 120)#include<stdio.h>#include<stdlib.h>int main(void) {...原创 2018-12-29 17:02:25 · 248 阅读 · 0 评论 -
C 判断一个数里有几个相同的数字问题
问题:Write a program that reads an integer, and determines and prints how many digits in the integer are 7s#include<stdio.h>#include<stdlib.h>int num;int a, b, c, d, e;int i = 0;...原创 2018-12-29 18:13:29 · 3504 阅读 · 0 评论 -
C 几个数的最值并求平均数问题
问题:Write a program that reads integers repeatedly and terminates when it reads 0The program should display below informationThe range of input numbers The average of input numbers (with 2 digi...原创 2018-12-29 19:17:13 · 447 阅读 · 0 评论 -
C语言主函数结构分析
int main( void )Every program in C begins executing at the function mainThe keyword int indicates that main “returns” an integer valueThe void Means that main does not receive any informatio...原创 2018-12-29 19:46:03 · 916 阅读 · 0 评论 -
C 求最大值和最小值问题
问题:Write a program that reads in five integersand then determines and prints the largest and the smallest integers in the group.#include<stdio.h>#include<stdlib.h>int main(void...原创 2018-12-25 21:43:09 · 4983 阅读 · 0 评论 -
C 平方、三次方输出问题
问题:write a program that calculates the squares and cubes of the numbers from 0 to 10 and uses tabs to print the following table of values:#include<stdio.h>#include<stdlib.h>int m...原创 2018-12-25 21:56:32 · 714 阅读 · 0 评论 -
C 拆分各个位上的数字,并抽取任意位上数计算问题
问题:Write a program :Inputs one five-digit number, separates the number into its individual digits1. Prints the digits separated from one another by three spaces each2. Prints the addition (and...原创 2018-12-25 22:39:53 · 1224 阅读 · 1 评论 -
Visual Studio 2017 怎么从a Windows App设置成 a Console App
为什么要转换设置?简单来说Windows Application的主函数是WinMain,而Windows Console Application的主函数是main原创 2018-12-25 22:59:41 · 1408 阅读 · 0 评论 -
C 用do-while语句求最大值问题
Probelm:Write a program that inputs a series of 5 numbers and determines and prints the largest of the numbers,Use ‘do-while’ statement#include<stdio.h>#include<stdlib.h>int ma...原创 2019-01-18 13:44:12 · 4756 阅读 · 0 评论 -
Visual Studio 2017 下载安装完整教程
官网下载地址:https://visualstudio.microsoft.com/zh-hans/vs/community/下面顺便说下字体设置问题:菜单栏选择“工具”-----> 选项-----> 环境----->字体和颜色 ------> 字体我们推荐使用 “Consolas”...原创 2019-01-09 21:17:36 · 7187 阅读 · 0 评论 -
C语言-底数幂问题
Write a program that reads two positive integers 'base' and 'exponent'.computes base to the power of exponent and prints.#include<stdio.h>#include<stdlib.h>#include<math.h>...转载 2019-03-19 21:07:34 · 219 阅读 · 0 评论 -
C语言-打印菱形图案问题
Write a program that prints the following diamond shapeYou may use printf statements that print either a single asterisk (*) or a single blankMaximize your use of repetition and minimize the numb...转载 2019-03-19 22:03:35 · 777 阅读 · 0 评论 -
C 判断奇偶数与循环输入实现
本节主要考察C语言基本语法中两个知识点 怎么判断奇数偶数问题 以及怎么实现重复输入的问题Problem 1Write a program that reads an integer and determines and prints whether it is odd or even. Hint:Use the reminder operator. An even numb...原创 2018-12-01 20:39:38 · 942 阅读 · 0 评论