自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 随机数问题

#include #include #include #include using namespace std;int main(){//伪随机数int r;srand(time(0));//以当前时间作为种子,每次循环自动更新//srand(static_cast<int>(time(nullptr)));//若上述语句收到警告,可用此行代替for(int i=0; i<10; i++){ r = rand(); cout << r

2021-05-18 21:36:26 81

原创 一直读入直至读入标记值(输入失败)

#include using namespace std;int main(){double salary;int counter = 0;double average;double sum;cout << "Inter salaries, -1 to finish:";while(salary != -1){ cin >> salary; if(salary!=-1) { counter += 1; sum

2021-05-13 07:29:35 71

原创 折半查找(C++)

折半查找必须采用顺序存储结构,而且表中元素按关键字有序排列原理与中值比较,不断缩小区间范围代码#include using namespace std;int BinarySearch(int a[], int low, int high, int target){while(low <= high){int mid = low + (high - low); //即(low + high)/2,这样写是防止溢出if(a[mid] > target) //若目标元素小

2021-04-18 00:07:38 985

原创 判断是否为素数(bool函数应用)

#include <stdio.h>#include <stdlib.h>#include <stdbool.h>bool IsPrime(int val){int i;//素数判断条件:除1和它本身外再没有其他公因数for(i =2; i <val; ++i){if(val%i == 0)break;}if(i == val)return true;elsereturn false;}int main(){//输出0到100之

2021-04-17 08:24:57 2792

原创 动态数组构建(malloc函数)

#include <stdio.h>#include <stdlib.h>#include <malloc.h>int main(){int len;int *pArr;int i; printf(“请输入数组长度: “); //用户提醒scanf(”%d”,&len);pArr = (int *)malloc(len * sizeof(int)); /*

2021-04-17 00:28:47 746

原创 结构体简单应用——制作一个简单的学生信息管理系统

#include <stdio.h>#include <stdlib.h>#include <malloc.h>struct student{int age;char name[100];float score;};int main(){int n;printf(“请输入学生个数: “);scanf(”%d”, &n);//构造动态数组struct student * pArr;pArr = (struct student *)ma

2021-04-16 00:05:02 311

原创 斐波那契数列

斐波那契数列—循环的简单应用

2021-04-15 08:53:19 49

原创 回文数的判断

回文数的判断(C语言)#include <stdio,h>#include <stdlib.h>| | |int main(){int val;int m;int sum = 0;printf("Please input a number: ");scanf("%d", &val);if(val == 0) break;else m = val; while(m) { sum = sum * 10 + m%10; //主题函数将整个数

2021-03-31 23:14:27 105

空空如也

空空如也

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

TA关注的人

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