算法练习
hjh1705072347
这个作者很懒,什么都没留下…
展开
-
算法练习2:Two fighters, one winner.
算法练习随笔2 题目: Create a function that returns the name of the winner in a fight between two fighters. Each fighter takes turns attacking the other and whoever kills the other first is victorious. Dea原创 2016-12-07 11:08:36 · 488 阅读 · 0 评论 -
算法练习3:Playing with digits
算法练习3 平方函数: pow(x,y);//即x的y次方 新建动态数组 cin>>len; int *p=new int[len]; -**建立线性链表:** #include struct student { int number; //数据域(学号) struct student *next;//指针域(地址) }; void main() {原创 2016-12-07 13:54:23 · 591 阅读 · 0 评论 -
算法练习1:Take every 2nd char from the string. Then the other chars 随笔
题目和要求: 十分全的string函数: http://www.jb51.net/article/41725.htm 可能用到的函数: -------删除函数 :erase(); #include using namespace std; ... string s1="asdfgh", s2; s2=s1.erase(2,3); //删除s1中从第2个字符原创 2016-12-06 14:47:13 · 498 阅读 · 0 评论 -
算法练习4:Buying a car
算法练习4 typedef struct 和struct : typedef struct Student { int a; }Stu; 在c++里面, typedef是别名的意思,Stu是Student的别名,定义 Stu test 即可 struct Student { int a; }st原创 2016-12-08 09:33:56 · 422 阅读 · 0 评论 -
算法练习5:Common Denominators
算法练习5 max函数: 需要用#include 格式:max(a,b);//只能比较两个数 三个数的比较:max(a,b>c?b:c);原创 2016-12-12 11:35:40 · 503 阅读 · 1 评论