![](https://img-blog.csdnimg.cn/20201014180756738.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C++基础编程
茄子爱跑步
keep coding...
展开
-
C++基础编程DAY18
45、写一函数,在一数组里查找某个值//写一函数,在一数组里查找某个值#include<iostream>#include<stdlib.h>using namespace std;int Search(int a[], int n, int key){ int i; for(i=0; i<n; i++) { if(a[i]==key) ...原创 2019-12-05 20:43:02 · 533 阅读 · 0 评论 -
C++基础编程DAY17(day)
37、写一个程序,进行体操评分,依次输入10名评委所评分数,去除一个最高分和一个最低分,再算出平均分作为选手的得分//写一个程序,进行体操评分,依次输入10名评委所评分数,//去除一个最高分和一个最低分,再算出平均分作为选手的得分。#include<iostream>#include<stdlib.h>using namespace std;float g...原创 2019-12-03 10:52:44 · 1157 阅读 · 0 评论 -
C++基础编程DAY16(day)
35、掷骰子10000次,统计得到各点数的次数//掷骰子10000次,统计得到各点数的次数#include<iostream>#include<stdlib.h>#include<time.h>using namespace std;/* 获得随机数1-6 */int get_randomNO(){ //int a; //a = rand...原创 2019-12-02 14:13:16 · 540 阅读 · 0 评论 -
C++基础编程DAY15(night)
33、打印杨辉三角(帕斯卡三角形),打印10行//打印杨辉三角(帕斯卡三角形),打印10行#include<iostream>#include<stdlib.h>#include<iomanip>using namespace std;/* 求n的阶乘 *///int f1(int n)//{// int s=1;// for(int ...原创 2019-12-01 22:04:16 · 241 阅读 · 0 评论 -
C++基础编程DAY15
31、输入一行字符串,统计其中英文小写字符的个数//输入一行字符串,统计其中英文小写字符的个数#include<iostream>#include<stdlib.h>#include<string>using namespace std;int count_lowercase(string str){ int count=0; for(i...原创 2019-12-01 15:57:07 · 195 阅读 · 0 评论 -
C++基础编程DAY14
30、百钱买百鸡问题:鸡翁一值钱五,鸡母一值钱三,鸡雏三值钱一,百钱买百鸡,问鸡翁、母、雏各几何?//百钱买百鸡问题:鸡翁一值钱五,鸡母一值钱三,//鸡雏三值钱一,百钱买百鸡,问鸡翁、母、雏各几何? #include<iostream>#include<stdlib.h>#include<ctime>using namespace std;/...原创 2019-11-30 21:58:06 · 269 阅读 · 1 评论 -
C++基础编程DAY13
27、写一个函数,交换两个整形变量的值//写一个函数,交换两个整形变量的值#include<iostream>#include<stdlib.h>using namespace std;int swap1(int x, int y){ int t; t = x; x = y; y = t; cout << x << ",...原创 2019-11-30 19:45:05 · 218 阅读 · 0 评论 -
C++基础编程DAY12
25、用筛法求1-1000以为的素数用筛法求素数的基本思想链接//用筛法求1-1000以为的素数#include<iostream>#include<iomanip>#include<stdlib.h>#include<math.h>using namespace std;bool isprime(int n){ float...原创 2019-11-28 16:00:35 · 180 阅读 · 0 评论 -
C++基础编程DAY11
23、求一个整数各位数之和的函数//求一个整数各位数之和的函数#include<iostream>#include<stdlib.h>using namespace std;int getSum(int n){ int sum = 0; while(n) { sum = sum + n%10; n = n/10; } return sum...原创 2019-11-25 09:55:26 · 216 阅读 · 0 评论 -
C++基础编程DAY10
21、写一个函数,将一个整数的各位数字的反序打印//写一个函数,将一个整数的各位数字的反序打印#include<iostream>#include<stdlib.h>using namespace std;//int reverse_out(int n)//{// while(n)// {// cout << n%10 << ...原创 2019-11-23 12:11:35 · 300 阅读 · 0 评论 -
C++基础编程DAY9
20、写一个函数,取一个整数值并返回此整数的各数字反序的数值//写一个函数,取一个整数值并返回此整数的各数字反序的数值#include<iostream>#include<stdint.h>using namespace std;//int reverse_m1(int x)//{// int y;// if(x>0 && x&l...原创 2019-11-21 20:38:04 · 248 阅读 · 0 评论 -
C++编程基础DAY8
18、编写一个函数,确定一个正数是否为完全数(一个数,等于除他自身以外的所有因子之和)。用这个函数确定和打印1到1000之间的所有完全数。//编写一个函数,确定一个正数是否为完全数(一个数,等于他的因子之和)。//用这个函数确定和打印1到1000之间的所有完全数。#include<iostream>#include<stdlib.h>using namespa...原创 2019-11-20 23:22:23 · 226 阅读 · 0 评论 -
C++基础编程DAY7(night)
16、写一函数,计算x的y次方,假设x, y都为正整数//写一函数,计算x的y次方,假设x, y都为正整数#include<iostream>#include<stdlib.h>using namespace std;int fun(int x, int y){ int a = 1; for(int i=0; i<y; i++) { a *...原创 2019-11-19 20:16:40 · 463 阅读 · 0 评论 -
C++基础编程DAY7(day)
输入20个数,统计其中正数、负数和零的个数我的代码//输入20个数,统计其中正数、负数和零的个数#include<iostream>#include<stdlib.h>using namespace std;int count_xyz(){ int a[10] = {0}; int x=0, y=0, z=0; for(int i=0; i<...原创 2019-11-19 11:53:41 · 742 阅读 · 0 评论 -
C++基础编程DAY6
求PI值,PI/4 = 1 - 1/3 + 1/5 - 1/7 + ……我的代码//求PI值,PI/4 = 1 - 1/3 + 1/5 - 1/7 + ……#include<iostream>#include<stdlib.h>#include<math.h>using namespace std;//double get_PI(int n)...原创 2019-11-18 15:33:14 · 226 阅读 · 0 评论 -
C++基础编程DAY5(day)
一、求和:S = 1!+2!+3!+……+10!我的代码//求和:S = 1!+2!+3!+……+10!#include<iostream>#include<stdlib.h>using namespace std;int getSum(int n){ int fac = 1, sum = 0; for(int i=1; i<(n+1); i++...原创 2019-11-17 12:04:21 · 167 阅读 · 0 评论 -
C++基础编程DAY4(night)
求和:s = 1x1 + 2x2 + 3x3 + … + 100x100求和:s = 1 + 2 + 2² + 2³ + …… + 2的63次方我的代码//求和:s = 1*1 + 2*2 + 3*3 + ... + 100*100//印度国王的奖励,求和:s = 1 + 2 + 2² + 2³ + …… + 2的63次方#include<iostream>#include...原创 2019-11-16 21:51:10 · 587 阅读 · 0 评论 -
C++基础编程DAY4(day)
要求:输入若干个数,设输入的第一个数为后面要输入的数的个数,求最大值和平均值我的代码//要求:输入若干个数,设输入的第一个数为后面要输入的数的个数,求最大值和平均值#include<iostream>#include<stdlib.h>using namespace std;int getMax(int *arr, int n){ int temp;...原创 2019-11-16 11:02:56 · 870 阅读 · 0 评论 -
C++基础编程DAY3(night)
要求:输入10个数,求最大值,最小值和平均值我的代码#include<iostream>#include<stdlib.h>using namespace std;int getMax(int *arr){ int temp; temp = *arr; //cout << temp << endl; for(int i=1; ...原创 2019-11-15 21:38:53 · 198 阅读 · 0 评论 -
C++基础编程DAY3(day)
要求:输入三个double类型的值,判断这三个值是否可以表示三角形的三条边我的代码#include<iostream>#include<stdlib.h>using namespace std;int ifTriangle(double a, double b, double c){ if(((a+b)>c) && ((a+c)>...原创 2019-11-15 11:48:20 · 900 阅读 · 0 评论 -
C++基础编程DAY2(night)
要求:输入一个成绩,打印相应的等级我的代码//输入一个成绩,打印相应的等级#include<iostream>#include<stdlib.h>#include<string>using namespace std;//int PrintLevel(int score)//{// int temp;// switch(temp = s...原创 2019-11-14 19:53:08 · 236 阅读 · 0 评论 -
C++基础编程DAY2(day)
求方程ax²+bx+c=0的根我的代码//求方程ax²+bx+c=0的根#include<iostream>#include<stdlib.h>#include<math.h>using namespace std;double fun(int a, int b, int c){ double temp, x, x1 = 0, x2 = ...原创 2019-11-14 11:53:53 · 232 阅读 · 0 评论 -
C++基础编程DAY1
要求:输入三个数,求最大值我的代码:#include<iostream>#include<stdlib.h>using namespace std;int getMax(int x, int y, int z){ int temp; if(x > y && x>z) { temp = x; } if(y>x &a...原创 2019-11-13 10:40:02 · 252 阅读 · 0 评论