随笔分类 -  c++

摘要:#include #include #include #include using namespace std; class Student { public: Student(string number="123", double score=0, const char *name="noname") { this->number = number; ... 阅读全文
posted @ 2019-06-06 00:07 浅滩浅 阅读(2486) 评论(0) 推荐(0)
摘要:7-1 数字格式异常 (10 分) 7-1 数字格式异常 (10 分) 7-1 数字格式异常 (10 分) (NumberFormatException数字格式异常)编写一个程序,提示用户读取两个整数,然后显示他们的和。程序应该在输入不正确时提示用户再次输入数字。 输入格式: i 9 (第1次输入) 阅读全文
posted @ 2019-06-04 19:39 浅滩浅 阅读(282) 评论(0) 推荐(0)
摘要:#include #include #include using namespace std; class Student { string name; char sex; int score; string grade; public: Student(string name, char sex, int score, string grade); ... 阅读全文
posted @ 2019-05-27 21:13 浅滩浅 阅读(340) 评论(0) 推荐(0)
摘要:#include #include using namespace std; class Student{ int grade; string name; public: static int num; Student(){ grade=0; name="123"; } Student(string b,int a):grade(a),n... 阅读全文
posted @ 2019-05-27 21:05 浅滩浅 阅读(121) 评论(0) 推荐(0)
摘要:题目描述 求Sn=a+aa+aaa+…+aa…aaa(有n个a)之值,其中a是一个数字,为2。 例如,n=5时=2+22+222+2222+22222,n由键盘输入。 输入 n 输出 Sn的值 样例输入 5 样例输出 24690 #include"stdio.h" int cal(int *p) { 阅读全文
posted @ 2019-05-21 22:35 浅滩浅 阅读(1308) 评论(0) 推荐(1)
摘要:题目描述计算机科学中的问题通常被归类为属于某一类问题(例如,NP,不可解,递归)。在这个问题中,您将分析算法的属性,该算法的分类对于所有可能的输入都是未知的。 考虑下面的算法: 1.输入n 2.输出n 3.如果n = 1,则停止 4.如果n是奇数,则n=3n + 1 5.否则n=n / 2 6.返回 阅读全文
posted @ 2019-05-18 11:07 浅滩浅 阅读(124) 评论(0) 推荐(0)
摘要:#include "iostream" #include "string" using namespace std; /*@author:浅滩 *family:c++中string类的简单介绍 *time:2019.2.12 */ int main() { string s;//string类的创建 /*下述均是string的成员函数*/ s = "123";//=直接进行赋值 cout ,... 阅读全文
posted @ 2019-05-18 10:56 浅滩浅 阅读(135) 评论(0) 推荐(0)
摘要:1 #include 2 3 #include 4 5 using namespace std; 6 7 // 你提交的代码将嵌入到这里 8 9 const int SIZE = 100; 10 11 template 12 13 class Queue { 14 15 T q[SIZE]; 16 17 i... 阅读全文
posted @ 2019-05-18 10:54 浅滩浅 阅读(99) 评论(0) 推荐(0)