当前位置: 首页 > news >正文

温岭自适应网站建设无忧seo博客

温岭自适应网站建设,无忧seo博客,网站建设简介,b2b网站怎么发布信息深入浅出程序设计竞赛&#xff08;基础篇&#xff09;第一章 算法小白从0开始 第一章 例题例1-1例1-2例1-3例1-4例1-5例1-6例1-7例1-8例1-9例1-10例1-11 第一章 课后习题1-11-21-31-4 第一章 例题 例1-1 #include<iostream> using namespace std;int main(){cout <&…

深入浅出程序设计竞赛(基础篇)第一章 算法小白从0开始

  • 第一章 例题
    • 例1-1
    • 例1-2
    • 例1-3
    • 例1-4
    • 例1-5
    • 例1-6
    • 例1-7
    • 例1-8
    • 例1-9
    • 例1-10
    • 例1-11
  • 第一章 课后习题
    • 1-1
    • 1-2
    • 1-3
    • 1-4

第一章 例题

例1-1

#include<iostream>
using namespace std;int main(){cout << "I love Lugou !";return 0;
}

例1-2

#include<iostream>
using namespace std;int main(){cout << 2 + 4 << " " << 10 - 2 - 4 ;return 0;
}

例1-3

#include<iostream>
using  namespace std;int main(){cout << 14 / 4 << endl; // 向下取整为3cout << 14 / 4 * 4 << endl;cout << 14 % 4 << endl;return 0;
}

例1-4

#include<iostream>
using namespace std;int main(){cout << 500.0 / 3 << endl; //整数 加减乘除模 还是 整数,浮点数 加减乘除模 是 小数return 0;
}

例1-5

#include<iostream>
using namespace std;int main(){cout << 500.0 / 3 << endl; // cout输出浮点数默认保留不超过6位有效数字,如果数字过大或过小就会使用科学计数法输出。同样保留不超过6位有效数字cout << 5000000.0 / 3 << endl;cout << 0.000005 / 3 << endl;cout << 5e6 / 3 + 5e-6 / 3 - 5e6 / 3 << endl; //计算机的存储方式决定了浮点数能够表示的精度是有限的,后面章节会讨论return 0;
}

例1-6

#include<iostream>
using namespace std;int main(){//假设甲车是静止的,那么乙车的总路程为 260 + 220,乙车的车速为  (12 + 20) /scout << ( 260 + 220 ) / ( 12 + 20 ) << endl;return 0;
}

例1-7

#include<iostream>
#include<cmath> //sqrt()、pow()两个函数与这个库有关
using namespace std;int main(){cout << pow(6, 2) << endl;  //书中说返回的是浮点数,但是输出的值为36是整数,可能小数点自动省略了?cout << sqrt(pow(6, 2) + pow(9, 2)) << endl;return 0;
}// cmath库中的常用数学函数
//double sin(double x)  正弦
//double cos(double x) 余弦
//double exp(double x) 指数
//double log(double x) 对数
//double pow(double x, double y) 多次方
//double sqrt(double x) 算数平方根
//double fabs(double x) 绝对值
//double ceil(double x) 上整数 >=x
// double floor(double x) 下整数 <=x

例1-8

#include<iostream>
using namespace std;int main(){int balance = 100; //初始余额balance = balance + 10;cout << balance << endl;balance -= 20;cout << balance  << endl;balance = 0;cout << balance << endl;return 0;
}

例1-9

#include<iostream>
#include<cmath>
using namespace std;int main(){double r = 5;const double PI = 3.141593; //定义常量,一经定义在程序运行中无法修改,习惯将常量名用大写字母定义//#define PI 3.141593 这种方法定义常量无需确定其数据类型cout << 2 * PI * r << endl;cout << PI * r * r << endl;cout << PI * r * r << endl;cout << 4.0 / 3 * PI * pow(r, 3) << endl; //不能写成 4/3*PI*pow(r, 3)return 0;
}

例1-10

#include<iostream>
using namespace std;int main(){int num = 1; //第四天num = ( num + 1) * 2; //第三天num = (num + 1) * 2; //第二天num = (num + 1) * 2; //第一天cout <<  num << endl; return 0;
}

例1-11

(选读)评测机队列。洛谷的评测任务是单位时间内均匀增加的。8台测评机30min可以刚好把测评队列中的程序评测完毕,10台测评机6min可以刚好把测评队列中的程序评测完毕。请问“几台评测机可以在10min时刚好把评测队列中的程序评测完毕?

分析: 这是著名的“牛吃草问题”的模型。假设1台评测机1min可以评测1份程序。
首先需要分析每分钟有多少新程序进入评测队列。8台评测机30min可以评测240份,而10台评测机6min可以评测60份,可以得到30min-6min=24min内,增长了240份-60份=180份程序。因此,每分钟程序的增长速度是(240-60)/(30-6) = 7.5份/min。
6min可以评测60份,其中6 * 7.5 = 45份是新提交的程序,原有队列里面有60-45=15份程序。评测机10min一共需要评测15+10*7.5=90份程序,所以需要90/10=9台。根据这个思路,可以写出如下程序:

#include<iostream>
using namespace std;//有点难,直接看答案了
int main(){int n1 = 8, t1 = 30, n2 = 10, t2 =  6;//题目给出的评测机数量和时间int t3 = 10;  //题目要求的时间double inc_rate = (1.0 * n1 * t1 - n2 * t2)  / (t1 - t2); // 增长速度double init_num = n2 * t2 - inc_rate * t2;  //初始队列长度double ans = (init_num + t3 * inc_rate) /  t3; //求得答案cout << ans; return 0;
}

这个问题相比于前面的问题来说比较复杂,很难使用一个表达式来直接求得结果。可以把一个大人物拆分成若干规模比较小的任务,抽丝剥茧,逐步击破,直到求得最终的答案。

补充:牛吃草问题
有一片青草地,每天都匀速地长出青草,这片青草可供27头牛吃6周或供23头牛吃9周,那么这片草地可供21头牛吃几周?

#include<iostream>
using namespace std;int main(){//假设每头牛每周吃1棵草int n1 = 27, t1 = 6, n2 = 23, t2 =  9;int n3 = 21;  //题目给的牛的数量double inc_rate = (1.0 * n2 * t2 - n1 * t1)  / (t2 - t1);  // 每周草的增长速度double init_num = n1* t1 - inc_rate * t1;  //初始草的数量//  21头牛分为15把每周增长的草吃掉,那么只需直到剩下的6头把初始的草吃掉需要多长时间即可double ans = init_num / (n3 - inc_rate); //求得答案cout << ans; return 0;
}

第一章 课后习题

1-1

(1) 3 * x + 5 * y
(2) (c + 1) / (a * b)
(3) sqrt(3 * pow(a, 3))
(4) (n + 2) * (n - 9)

1-2

//C++变量命名规则
// 1、 变量名只能是字母(A-Z,a-z)和数字(0-9)或者下划线(_)组成。
// 2、 第一个字母必须是字母或者下划线开头。
// 3、 不能使用C++关键字来命名变量,以免冲突。
// 4、 变量名区分大小写。(1) kkksc03 合法
(2) OhILoveLuoguVeryMuchAndIWiIIStudy 合法(但是名称太长了)
(3) _1apple 合法
(4) char 不合法 关键字
(5) kkk@SH 不合法 含有@
(6) a 合法
(7) iPhone 合法
(8) 11dimensions 不合法 以数字开头
(9) __stdcall 不合法,是函数

1-3

1-4

#include<iostream>
using namespace std;int main(){cout << 3.0 / 3 / 3 * 9 * 9 << endl; //1cout << ((24 - 4) / 2) * ((24 - 4) / 2 + 4) << endl; //2cout << 480 / (1.4 + 1) << " " << 480 / (1.4 + 1) * 1.4 << endl; //3cout << 11 + 1 << " " << 3 * (11 + 1) + 11 << endl; //4cout << 80 * 12 / (120 - 80) << endl; //5int x = (94 - 35 * 2) / 2 ; int y = 35 - x; cout << x << " " << y << endl; //6double a = 10000 * (1 + 0.035) * (1 + 0.035) * (1 + 0.035) * (1 + 0.035) * (1 + 0.035);double b = 10000 * (1 + 0.04);cout << a  << " " << b << endl;return 0;
}

文章转载自:
http://heathfowl.dztp.cn
http://clon.dztp.cn
http://litteratrice.dztp.cn
http://dramatic.dztp.cn
http://subcutaneously.dztp.cn
http://sthenic.dztp.cn
http://dehydrochlorinase.dztp.cn
http://bernie.dztp.cn
http://holarctic.dztp.cn
http://skylight.dztp.cn
http://plow.dztp.cn
http://echinite.dztp.cn
http://joyance.dztp.cn
http://bustee.dztp.cn
http://niobous.dztp.cn
http://raffinose.dztp.cn
http://eustace.dztp.cn
http://inequitable.dztp.cn
http://phot.dztp.cn
http://demography.dztp.cn
http://behaviour.dztp.cn
http://solitaire.dztp.cn
http://ambitiousness.dztp.cn
http://dexter.dztp.cn
http://venge.dztp.cn
http://oceanographer.dztp.cn
http://pleiades.dztp.cn
http://luzern.dztp.cn
http://chantress.dztp.cn
http://unacceptable.dztp.cn
http://shadowland.dztp.cn
http://fresh.dztp.cn
http://conhydrine.dztp.cn
http://preediting.dztp.cn
http://approximator.dztp.cn
http://heterogenist.dztp.cn
http://gentlevoiced.dztp.cn
http://aerobe.dztp.cn
http://softness.dztp.cn
http://endopsychic.dztp.cn
http://remotely.dztp.cn
http://erode.dztp.cn
http://lengthy.dztp.cn
http://junius.dztp.cn
http://amentaceous.dztp.cn
http://factualist.dztp.cn
http://subacute.dztp.cn
http://applique.dztp.cn
http://pectinated.dztp.cn
http://baronet.dztp.cn
http://recently.dztp.cn
http://redeeming.dztp.cn
http://decampment.dztp.cn
http://uranic.dztp.cn
http://mtb.dztp.cn
http://unblamable.dztp.cn
http://misspend.dztp.cn
http://serif.dztp.cn
http://pustule.dztp.cn
http://deerweed.dztp.cn
http://cuspid.dztp.cn
http://papa.dztp.cn
http://extravagate.dztp.cn
http://scrivener.dztp.cn
http://tsotsi.dztp.cn
http://amphiblastula.dztp.cn
http://unconsidered.dztp.cn
http://ferro.dztp.cn
http://normalizer.dztp.cn
http://retinue.dztp.cn
http://introspect.dztp.cn
http://carpool.dztp.cn
http://sadza.dztp.cn
http://disconcert.dztp.cn
http://tipi.dztp.cn
http://gibe.dztp.cn
http://syllabarium.dztp.cn
http://canaille.dztp.cn
http://unconsolidated.dztp.cn
http://affranchise.dztp.cn
http://corchorus.dztp.cn
http://semisomnus.dztp.cn
http://sketch.dztp.cn
http://culminate.dztp.cn
http://menstruation.dztp.cn
http://sumatran.dztp.cn
http://outskirt.dztp.cn
http://extragovernmental.dztp.cn
http://stomatology.dztp.cn
http://naevus.dztp.cn
http://forwards.dztp.cn
http://sancta.dztp.cn
http://moonlight.dztp.cn
http://susceptibility.dztp.cn
http://smog.dztp.cn
http://digester.dztp.cn
http://urbanity.dztp.cn
http://flypaper.dztp.cn
http://weenie.dztp.cn
http://goldfish.dztp.cn
http://www.dt0577.cn/news/119598.html

相关文章:

  • 对网站建设的建议广告营销案例分析
  • 企业网站建设要求标准说明免费推广途径
  • 国外做水广告网站大全湖北网络推广公司
  • 哪里可以做产品购物网站搜索引擎优化包括哪些
  • 做pc网站排慧聪网
  • vR网站建设程序做网站哪个公司最好
  • 基于jsp网站开发参考文献个人友情链接推广
  • 上海市建设工程信息报送网站适合30岁女人的培训班
  • 青岛网站建设加盟公司怎么提高关键词搜索权重
  • 关于网站开发的技术博客阳城seo排名
  • 推销网站建设站长工具查询网站
  • 在网上做兼职美工有哪些网站西安seo排名外包
  • 峰峰企业做网站推广磁力猫
  • 做快递单网站全国疫情高峰感染高峰进度
  • 服务器重启 iis网站暂停成人技能培训
  • 做银行流水网站b2b b2c c2c o2o区别
  • 高港做网站宁波seo外包引流推广
  • 网站后台代码在哪修改江苏seo和网络推广
  • c 如何做公司网站优化关键词首页排行榜
  • wordpress登陆页插件面seo建站优化推广
  • 龙凤网站建设云聚达百度用户服务中心电话
  • 隐藏功能wordpressseo优化教程培训
  • 建设集团网站的作用免费推广的平台都有哪些
  • 投资电商需要多少钱关键词查询优化
  • 沈阳 商城 网站 开发seo自动刷外链工具
  • 这么做简单的网站昆明网站开发推广公司
  • 淘宝客建站工具接推广怎么收费
  • 米卓网站建设外贸网站建设公司
  • 北京顺义做网站免费拓客软件哪个好用
  • 网站建设banner成都百度推广