摘要: No.1390 代码:https://code.csdn.net/snippets/191965 另一版本:https://code.csdn.net/snippets/192009考察点有两个:①将一个数转换为指定进制的数 ②判断是否为回文数vector num;num.insert(num.begin(), j);向 vector 的指定位置插入元素,对于 vector 它不像 list 和 deque 可以调用 num.push_front(j) 来向队列最前端插入元素,因而只能使用 num.insert()。对于10进制以上的进制,当某一位的数字大于等于10之后,就需要将其转换成 ‘A 阅读全文
posted @ 2014-02-17 21:41 阿祖叔叔 阅读(179) 评论(0) 推荐(0) 编辑
摘要: No.2283No.1387vector > before, after;可以创建一个容器的容器,注意 char 后的两个 “>” ,之间必须有一个空格,否则会被当做是右移操作 “>>” 来处理。如何向一个容器的容器传值呢,可以参照以下方法: int n; cin>>n; vector > before; vector oneline; char tmp; int i, j; for(i=0; i>tmp; oneline.push_back(tmp); } before.push_back(oneli... 阅读全文
posted @ 2014-01-14 11:27 阿祖叔叔 阅读(184) 评论(0) 推荐(0) 编辑
摘要: No. 2878 No. 2559都是输入两个数,让你来判断是否符合要求的特别注意 2878 , 题目中要求1<=a,b<=2^64-1(2的64次方-1)=18446744073709551615而在 c++ 中,只有unsigned long long 的最大值是 18446744073709551615若用unsigned long long,则要分别 a%5 b%5,不能乘积后再%或者用字符串,判断最后一位是否是‘0’或‘5’2559则是注意输出 阅读全文
posted @ 2014-01-07 11:14 阿祖叔叔 阅读(130) 评论(0) 推荐(0) 编辑
摘要: No. 1468已知三角形的三条边求面积:海伦公式S=√[p(p-a)(p-b)(p-c)] p=(a+b+c)/2#include cmath 是 c++ 语言中的库函数,其中的 c 表示函数是来自 c 标准库的函数,math 为数学常用库函数。常用的公式有1 三角函数doublesin (double);doublecos (double);doubletan (double);2 反三角函数doubleasin(double);结果介于[-PI/2,PI/2]doubleacos(double);结果介于[0,PI]doubleatan(double);反正切(主值),结果介于[-PI/ 阅读全文
posted @ 2014-01-07 10:24 阿祖叔叔 阅读(148) 评论(0) 推荐(0) 编辑
摘要: No. 3040代码量好少,主要考到数学知识唯一需要注意的是变量的类型int-2147483648 ~ +2147483647 (4 Bytes)long 在32位机器中 int 类型 和 long 类型通常字长是相同的 = int(4Bytes) 在64位机器中 = int64_t-9223372036854775808 ~ +9223372036854775807(8 Bytes)long long= int64_t-9223372036854775808 ~ +9223372036854775807(8 Bytes) long long int 不是所有编译器都支持的,有些支持这种数.. 阅读全文
posted @ 2014-01-06 11:24 阿祖叔叔 阅读(149) 评论(0) 推荐(0) 编辑
摘要: No. 1385挤牛奶问题Tips: 查找之前对数据进行一下排列会比较好; 两个“最长”放在一趟遍历里查找。class LT{public: int bt; int ct; int duration; LT(): bt(0), ct(0), duration(0) {} LT& operator=(LT one) { bt=one.bt; ct=one.ct; duration=one.duration; return *this; }};赋值操作符重载时,必须返回对 *this 的引用 阅读全文
posted @ 2014-01-05 11:02 阿祖叔叔 阅读(107) 评论(0) 推荐(0) 编辑
摘要: No. 1384这题没啥不过网考成绩出了,发现我的口语分数相较其他人还挺高的~~~哈哈哈Code::Blocks 有时在程序运行结束后,.exe 并没有结束,因而之后无论怎么调试和修改代码,运行的 exe 文件都是此 exe需要自己手动在任务管理器中结束此 exe 进程(坑爹,太浪费时间了)Code::Blocks 关闭拼写检查的方法:在 Plugins 的下拉列表中,选择最后一个Manage plugins打开后,找到SpellChecker 将其设为 Disable 即可 switch(j) { case 1: ... 阅读全文
posted @ 2013-12-27 11:28 阿祖叔叔 阅读(157) 评论(0) 推荐(0) 编辑
摘要: No. 1381容器相关#include 头文件vector present; present.push_back(name);向 vector 中插入元素present.size();常用,获取当前容器的元素个数 阅读全文
posted @ 2013-12-26 10:36 阿祖叔叔 阅读(147) 评论(0) 推荐(0) 编辑
摘要: No. 1505文件读相关#include #include 支持文件的IO不加的话,若使用 istringstream 类型,会出现错误error: variable ‘std::istringstream stream’ has initializer but incomplete type string file="1.txt"; ifstream infile; infile.open(file.c_str(), fstream::in | fstream::out);以上代码可以用来打开一个文件,构造一个 ifstream 的读文件流,并同 file 绑定使用 o 阅读全文
posted @ 2013-12-25 11:29 阿祖叔叔 阅读(369) 评论(0) 推荐(0) 编辑
摘要: #include exit(0); #include 是exit(0) 必须的头文件 否则会出现exit was not declared in this scope的编译错误#include cout 是必须的,它是I/O流控制头文件,进行输出格式控制 cin.clear(); cin.sync(); cin.get(); 可以使程序暂停,等待键盘输入后继续执行 不应该使用 system("pause") 阅读全文
posted @ 2013-12-18 11:59 阿祖叔叔 阅读(318) 评论(0) 推荐(0) 编辑