2019年10月12日

C++中对C的扩展学习新增语法——作用域运算符::

摘要: 作用域运算符用来告诉编译器在哪个作用域范围搜索符号,一般分为以下3种: 全局作用域: 命名空间作用域: 类作用域: 阅读全文

posted @ 2019-10-12 15:02 YanShnY 阅读(407) 评论(0) 推荐(0)

C++中对C的扩展学习新增语法——namespace

摘要: NAMESPACE语法 namespace主要解决了命名冲突的问题,语法如下 Namespace注意事项: 4.namespace是开放的,可以随时添加新成员。 5.namespace 关键字可以为已有空间名字增加别名,例如 6.无名命名空间意味着命名空间中的符号只能在本文件中访问,相当于给符号增加 阅读全文

posted @ 2019-10-12 14:37 YanShnY 阅读(294) 评论(0) 推荐(0)

2019年9月27日

插入排序的代码实现(C语言)

摘要: void insert_sort(int arr[], int len) { for (int i = 1; i < len; ++i) { if (arr[i] < arr[i - 1]) { int temp = arr[i]; int j = i - 1; for (; j >= 0 && a 阅读全文

posted @ 2019-09-27 21:06 YanShnY 阅读(1216) 评论(0) 推荐(0)

2019年9月21日

实现两个数字的交换(C语言)

摘要: int num1=10; int num2=20; //1、简单的数学方法实现数字交换 num1=num1+num2;//num1=30 num2=num1-num2;//num2=10 num1=num1-num2;//num1=20 //2、利用按位异或实现数字交换 num1=num1^num2 阅读全文

posted @ 2019-09-21 20:16 YanShnY 阅读(2469) 评论(0) 推荐(0)

2019年9月20日

斐波那契数列的实现(C语言)

摘要: int fibonacci(int positon){ if(position==1||position==2){ return 1; } return fibonacci(position-1)+fibonacci(position-2); } void test(){ int result=fi 阅读全文

posted @ 2019-09-20 21:04 YanShnY 阅读(3436) 评论(0) 推荐(0)

简单的倒叙应用---倒序打印字符串(C语言)

摘要: void reverseStr(char* str){ if(*str=='\0'){ return; } reverseStr(str+1); printf("%c\n",*str); } void test(){ char * str = "abcdefg"; reverseStr(str); 阅读全文

posted @ 2019-09-20 20:57 YanShnY 阅读(706) 评论(0) 推荐(0)

2019年8月27日

用c语言打印一个三角形

摘要: #define _CRT_SECURE_NO_WARNINGS#include<stdio.h>#include<string.h>#include<stdlib.h>#include<math.h>#include<time.h> int main(){ int n; printf("请输入想要打 阅读全文

posted @ 2019-08-27 21:19 YanShnY 阅读(2376) 评论(0) 推荐(0)

2019年8月26日

C语音中最简单的排序冒泡排序和选择排序代码实现(非指针)

摘要: #include<stdio.h> int main() { int a[5] = { 2,5,7,3,-1 }; int n = sizeof(a) / sizeof(a[0]);//元素个数 for (int i = 0; i < n - 1; i++) {//比较轮数 for (int j = 阅读全文

posted @ 2019-08-26 21:00 YanShnY 阅读(347) 评论(0) 推荐(0)

导航