- 博客(16)
- 资源 (7)
- 收藏
- 关注
原创 习题4.1游泳池改造
/*在一圆形游泳池周围建一圆形过道,并在过道周围安上栅栏。栅栏每米价格为35元,过道每平方米价格为20元。过道宽度为3米。游泳池半径有键盘输入。求过道和栅栏的造价 */#include using namespace std; const float PI=3.1415926;const float FENCE_PRICE=35;//每米栅栏的价格 const float CON
2014-10-29 20:55:08 1183
原创 习题3.6求两整数的最大公约数和最小公倍数
/*如果有一个自然数a能被自然数b整除,则称a为b的倍数,b为a的约数最大公约数:指两个或多个整数共有约数中最大的一个辗转相除法(欧几里德算法)例如,求(319,377):∵ 319÷377=0(余319)∴(319,377)=(377,319);∵ 377÷319=1(余58)∴(377,319)=(319,58);∵ 319÷58=5(余29),∴ (319,58)=(5
2014-10-29 18:59:07 871
原创 习题3.5求角度的正弦值
#include #include using namespace std; const double PI=3.1415926535879;int main() { double angle; cout<<"请输入角度"<<endl; cin>>angle; double radian=angle*PI/180; cout<<"sin("<<angle<<")="<<(in
2014-10-22 21:33:17 1182
原创 习题3.4求n!(递归)
using namespace std;/*计算n的阶乘*/unsigned int fac(unsigned int n){ unsigned int sum=n; while(--n) { sum*=n; } return sum;} int main() { unsigned int n; cout<<"请输入n"<<endl; cin>>n; cout<<f
2014-10-22 20:58:43 401
原创 习题3.3投骰子的随机游戏
/*题目:每个骰子有六面,点数分别为1,2,3,4,5,6。游戏者在开始输入一个无符号整数,作为产生随机数的种子。每次投两次骰子,第一轮如果和数为7或11则为胜,游戏结束;和数为2,3或12则为败,游戏结束;和数若为其他数则将此值作为自己的点数,继续第二轮,第三轮···直至和数等于点数,则取胜,或出现和数为7,则为败 *///系统函数int rand(void)的功能是产生一个伪随机数,
2014-10-22 20:47:20 2346
原创 习题3.2回文数
/*题目:寻找11~999之间的数n,它满足n,n^2,n^3均为回文数 */#include using namespace std; /*判断是否为回文数*///按照反序重新构建新的数,与原数比较是否相等bool symm(unsigned int n){ unsigned int i=n; unsigned int m=0; while(i) { m=10*m
2014-10-22 20:20:53 564
原创 习题3.1二进制转为十进制
/*题目:输入一个八位的二进制数,将其转为十进制数输出 *//*分析:例:(00001101)2=0*2^7+0*2^6+0*2^5+0*2^4+1*2^3+1*2^2+0*2^1+1*2^0*/ #include using namespace std;int power(int x,int n){ int value=1; while(n--) { value*=
2014-10-22 20:01:02 2781
原创 习题1.4九九乘法表
/*1*1=11*2=2 2*2=41*3=3 2*3=6 3*3=91*4=4 2*4=8 3*4=12 4*4=161*5=5 2*5=10 3*5=15 4*5=20 5*5=251*6=6 2*6=12 3*6=18 4*6=24 5*6=30 6*6=361*7=7 2*7=14 3*7=21 4*7=28 5*7=35 6*7=42 7*7=491*8=
2014-10-15 17:45:27 500
原创 习题1.3从五色球中取三色球的取法
/*题目口袋中有红,黄,蓝,白,黑5种颜色的求若干。每次从口袋中取出3个不同颜色的球,问有多少种取法*/#include using namespace std; int main() { int total=0; for(int one=0;one<5;one++) { for(int two=0;two<5;two++) { if(one!=two) {
2014-10-15 13:45:26 1280
原创 习题1.2找出1~100中的质数(穷举法)
/*找出1~100中的质数(穷举法) */#include #includeusing namespace std; int main() { for(int number=2;number<=100;number++) { int i=2; for(;i<=(int)sqrt(number);i++) { if(number%i==0) { bre
2014-10-15 10:45:12 5032
原创 习题1.1闰年判断
/*闰年能被4整除却不能被100整除或能被400整除 ((year%4==0)&(year%100!=0))|(year%400==0)*/#include using namespace std; int main() { unsigned int year; cout<<"please enter the year"<<endl; cin>>year; if(((year%
2014-10-15 10:35:28 426
原创 cin cout
先看最简单的一个例子,熟悉一下#include //#include为 预处理指令;文件iostream中声明了程序所需要的输入输出操作的有关信息using namespace std;//using namespace是针对命名空间的指令int main() { string pri; cin>>pri;//cin是一个输入流对象,输入操作由操作符“>>”来表示 cout<<p
2014-10-14 20:22:42 765
原创 Dev C++下载
Dev C++历史版本下载:http://sourceforge.net/projects/orwelldevcpp/files/Setup%20Releases/
2014-10-09 16:03:15 4165
mat格式的MNIST数据
2019-03-04
MNIST手写数字数据库
2019-03-04
Normalized Brodatz Texture
2019-02-25
Original Brodatz Texture
2019-02-25
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人