c++
编程雏鸟
这个作者很懒,什么都没留下…
展开
-
做题做题,学无止尽 -1
学习,逐步成长原创 2023-03-10 13:11:22 · 121 阅读 · 0 评论 -
简单的小游戏:寻找宝藏(粗糙版)
#include <iostream>#include <ctime>#include <windows.h>/* Sleep(1000);*/#include <cstdlib>/* srand (time(0));*/using namespace std;int main(){ cout<<"找宝藏游戏,欢迎您!"<<endl; cout<<"如果超出迷...原创 2021-09-12 11:32:45 · 170 阅读 · 0 评论 -
简单版的约瑟夫环问题编程:清除隔壁编号的
根据查找的只是发现约瑟夫环是有规律的;清除隔壁编号的人的总数:1——2——3——4——5——6——7——(对应下面的存活位置)存活位置:1——1——3——1——3——5——7——一号清除号,三号清除四号.....一圈后会发现,偶数位置的都被清除了。剩下的继续 ....得到公式:X(总人数)=2^n+a; Y(存活位置)=2a+1;其中位置的就是n和a。需要求出来!(写的很简单)#include <iostream>using nam...原创 2021-09-01 14:14:30 · 89 阅读 · 0 评论 -
C++:猜数字大小的小游戏(随机生成100以内的整数)
做一个简单的小白都能看懂的(主要运用到for循环和if判断语句)#include<iostream>#include <windows.h>#include <stdio.h>#include <stdlib.h>#include <time.h>using namespace std;int main(){ cout<<"玩一个猜数字游戏(一到一百),你有五次机会!"<<endl; sra...原创 2021-08-31 16:19:21 · 1157 阅读 · 0 评论 -
经典C++一百题:随便输入十个数字,之后将自行从小到大进行排序
不知道有没有BUG,哈哈哈我感觉可以运行!#include <iostream>#include <windows.h>using namespace std;int main(){ cout<<"随便输入是十数字,之后将自行从小到大进行排序:"<<endl;Sleep (4000);//美观system("cls");//美观float a[9];float b,temp; for(int i=0;i<=9;i++...原创 2021-08-29 13:51:18 · 299 阅读 · 0 评论 -
经典C++一百题:100以内的素数一共有多少个
首先素数是指这个数只有1和它本身相乘,不能被2,3,5,7整除。所以我们可以根据这个特性。作出以下程序代码:#include <iostream>using namespace std;int main(){ float a,b,c,d,e;//存放数,随便设置 e=0;//素数的个数 cout<<"2"<<endl; cout<<"3"<<endl; cout<<"5"<&...原创 2021-08-29 12:59:01 · 396 阅读 · 0 评论 -
经典C++一百题之:阶乘的和
1!+2!+3!.....的和这种题目#include <iostream>using namespace std;int main(){ int sum=0;//阶乘和int ji=1;//阶乘int j;//控制任意阶乘数cout<<"请输入你想要的阶乘和:"<<endl;cin>>j;for(int i=1;i<=j;i++){ ji=ji*i; sum=ji+sum;}...原创 2021-08-29 10:21:31 · 94 阅读 · 0 评论 -
猴子吃桃的故事
猴子吃桃问题:猴子第一天摘下若干个桃子,当即吃了一半,还不过瘾,又多吃了一个;第二天早上又将剩下的桃子吃掉一半,又多吃了一个;以此往后,到第十天早上想再吃时,就只剩一个桃子了。求第一天共摘了多少个桃子。#include <iostream>using namespace std;int main(){int tao=1;//第十天的桃子数量for (int i=1;i<10;i++)//利用FOR循环进行逆推{ tao=(tao+1)*2; }...原创 2021-08-28 16:41:20 · 187 阅读 · 0 评论