c++:自己设计一个vector类的问题~~~~~~~~~

请问这个问题不用模板怎么写。。。。。。。。
题目描述
模拟STL vector类设计实现你的vector类,该类需具有动态分配和扩张功能,并能拷贝构造和赋值;利用该类实现本题要求。

输入描述
先读入m,n两个正整数,分别构造具有m,n个元素的两个向量容器,并将第一个容器的元素设置为1~m,将第二个容器的元素设置为0~2 ×(n-1);再将第二个容器复制构造第三个向量容器,再读入若干对整数v、x, 1<=v<=3; 将x追加在第v个容器后;

输出描述
最后输出三个容器中元素;每个容器占一行,元素间以空格分隔。

输入样例
4 5
1 100
2 200
3 300
2 400

2个回答

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
c++:自己设计一个vector类的问题~~~~~~~~~
请问这个问题不用模板怎么写。。。。。。。。 题目描述 模拟STL vector类设计实现你的vector类,该类需具有动态分配和扩张功能,并能拷贝构造和赋值;利用该类实现本题要求。 输入描述 先读入m,n两个正整数,分别构造具有m,n个元素的两个向量容器,并将第一个容器的元素设置为1~m,将第二个容器的元素设置为0~2 ×(n-1);再将第二个容器复制构造第三个向量容器,再读入若干对整数v、x, 1<=v<=3; 将x追加在第v个容器后; 输出描述 最后输出三个容器中元素;每个容器占一行,元素间以空格分隔。 输入样例 4 5 1 100 2 200 3 300 2 400
怎么使用虚函数设计类似PPT页的类CPPage?
要求:(C++环境下) 设计CGraph为抽象类, 设计的成员函数,定义Show为虚函数,用于显示属性值。 使CRect和CEllipse类公有继承自CGraph; 设计CRoundRect类,使其公有多继承自CRect和CEllipse类; 在CPPage内中用CGraph* 指针数组(或Vector)的方式存储各图形对象( CRect、CEllipse和CRoundRect图形对象) 求完整详细的代码过程,可运行出结果
C++关于模板类引用作为返回值的问题
跟着《C++程序设计原理与实践》编写vector容器的模板实现,在编写vector的拷贝函数时出现了该函数未定义的问题, 在模板类vector中该函数定义如下: vector<T>& operator=(const vector<T>&); //改成vector& operator=(const vector&); 也不行弹出的错误代码是一样的 该函数声明如下: vector<T>& vector<T>::operator=(const vector<T>& v) { if(this == &v) return *this; if(v.sz <= sp) { for(int i=0; i<v.sz; i++) elem[i] = v.elem[i]; sz = v.sz; return *this; } T* cp = new T[v.sz]; copy(v.elem, v.elem + v.sz, cp); delete[] elem; sp = sz = v.sz; elem = cp; return *this; } Main函数中这样使用的 vector<int> v(2); vector<int> v2{1}; # v = v2; //问题就出现在这了~ 错误代码如下: “对‘vector<int>::operator=(vector<int> const&)’未定义的引用 ” //为什么vector源码中没有对'='的重载呢? 使用g++11编译的,希望能获得大神的解答,谢谢啦
为什么我看了这个关于高校人员信息管理系统设计的代码运行时总是会说找不到“common.h”这个文件,这个那里有错误呢?
#ifndef COMMON_H_INCLUDED #define COMMON_H_INCLUDED #include<string> #include<iostream> #include<iomanip> class COMMON { protected: std::string name; bool sex; int age; std::string id; static int person_sum; static int man_sum; static int woman_sum; public: COMMON(std::string a, bool b, int c, std::string d); virtual ~COMMON(); static int get_person_sum(); static int get_man_sum(); static int get_woman_sum(); virtual void show(){} virtual void show_row(){} virtual bool change(){} std::string get_name(){return name;} bool get_sex(){return sex;} int get_age(){return age;} std::string get_id(){return id;} }; int COMMON::person_sum = 0; int COMMON::man_sum = 0; int COMMON::woman_sum = 0; int COMMON::get_person_sum() { return person_sum; } int COMMON::get_man_sum() { return man_sum; } int COMMON::get_woman_sum() { return woman_sum; } COMMON::COMMON(std::string a, bool b, int c, std::string d): name(a), sex(b), age(c), id(d) { person_sum++; if(b) man_sum++; else woman_sum++; } COMMON::~COMMON() { person_sum--; if(sex) man_sum--; else woman_sum--; } #endif // COMMON_H_INCLUDED tester.h 实验员: #ifndef TESTER_H_INCLUDED #define TESTER_H_INCLUDED #include"common.h" class TESTER: public COMMON { private: std::string laboratory; std::string title; static int tester_sum; public: TESTER(std::string a = "haha", bool b = 1, int c = 19, std::string d = "1", std::string e = "tt", std::string f = "学生"); ~TESTER(); static int get_tester_sum(); virtual void show(); virtual void show_row(); virtual bool change(); std::string get_laboratory(){return laboratory;} std::string get_title(){return title;} }; int TESTER::tester_sum = 0; int TESTER::get_tester_sum() { return tester_sum; } TESTER::TESTER(std::string a, bool b, int c, std::string d, std::string e, std::string f): COMMON(a,b,c,d), laboratory(e), title(f) { tester_sum++; } TESTER::~TESTER() { tester_sum--; } void TESTER::show() { std::cout << "实验员:\n"; std::cout << "姓名:\t\t" << name << std::endl; std::cout << "姓别:\t\t"; if(sex) std::cout << "男\n"; else std::cout << "女\n"; std::cout << "年龄:\t\t" << age << std::endl; std::cout << "ID:\t\t" << id << std::endl; std::cout << "所属实验室:\t" << laboratory << std::endl; std::cout << "职务:\t\t" << title << std::endl; } void TESTER::show_row() { std::cout << std::left << std::setw(8) << name; if(sex) std::cout << std::left << std::setw(8) << "男"; else std::cout << std::left << std::setw(8) << "女"; std::cout << std::left << std::setw(8) << age; std::cout << std::left << std::setw(16) << id; std::cout << std::left << std::setw(16) << laboratory; std::cout << std::left << std::setw(16) << title; std::cout << std::endl; } bool TESTER::change() { std::cout << "姓名:\t\t" ; std::string new_name; std::cin >> new_name; for(unsigned int i = 0; i < new_name.length(); i++) { if(new_name[i] >= '0' && new_name[i] <= '9') { std::cout << "输入非法,输入任意键返回\n"; return 1; } } name = new_name; std::cout << "姓别:\t\t"; std::string a; std::cin >> a; if(sex) man_sum--; else woman_sum--; if(a == "男") sex = 1, man_sum++; else sex = 0, woman_sum++; std::cout << "年龄:\t\t"; std::cin >> age; std::cout << "所属实验室:\t"; std::cin >> laboratory; std::cout << "职务:\t\t"; std::cin >> title; return 0; } #endif // TESTER_H_INCLUDED teacher.h 教师: #ifndef TEACHER_H_INCLUDED #define TEACHER_H_INCLUDED #include"common.h" class TEACHER: virtual public COMMON { protected: std::string department; std::string profession; std::string title; static int teacher_sum; public: TEACHER(std::string a = "xixi", bool b = 1, int c = 30, std::string d = "213", std::string e = "计算机与信息工程学院", std::string f = "计算机科学与技术", std::string g = "教师"); ~TEACHER(); static int get_teacher_sum(); virtual void show(); virtual void show_row(); virtual bool change(); std::string get_department(){return department;} std::string get_profession(){return profession;} std::string get_title(){return title;} }; int TEACHER::teacher_sum = 0; int TEACHER::get_teacher_sum() { return teacher_sum; } TEACHER::TEACHER(std::string a, bool b, int c, std::string d, std::string e, std::string f, std::string g): COMMON(a,b,c,d), department(e), profession(f), title(g) { teacher_sum++; } TEACHER::~TEACHER() { teacher_sum--; } void TEACHER::show() { std::cout << "教师:\n"; std::cout << "姓名:\t\t" << name << std::endl; std::cout << "姓别:\t\t"; if(sex) std::cout << "男\n"; else std::cout << "女\n"; std::cout << "年龄:\t\t" << age << std::endl; std::cout << "ID:\t\t" << id << std::endl; std::cout << "院系:\t\t" << department << std::endl; std::cout << "专业:\t\t" << profession << std::endl; std::cout << "职务:\t\t" << title << std::endl; } void TEACHER::show_row() { std::cout << std::left << std::setw(8) << name; if(sex) std::cout << std::left << std::setw(8) << "男"; else std::cout << std::left << std::setw(8) << "女"; std::cout << std::left << std::setw(8) << age; std::cout << std::left << std::setw(16) << id; std::cout << std::left << std::setw(16) << department; std::cout << std::left << std::setw(16) << profession; std::cout << std::left << std::setw(16) << title; std::cout << std::endl; } bool TEACHER::change() { std::cout << "姓名:\t\t" ; std::string new_name; std::cin >> new_name; for(unsigned int i = 0; i < new_name.length(); i++) { if(new_name[i] >= '0' && new_name[i] <= '9') { std::cout << "输入非法,输入任意键返回\n"; return 1; } } name = new_name; std::cout << "姓别:\t\t"; std::string a; std::cin >> a; if(sex) man_sum--; else woman_sum--; if(a == "男") sex = 1, man_sum++; else sex = 0, woman_sum++; std::cout << "年龄:\t\t"; std::cin >> age; std::cout << "院系:\t\t"; std::cin >> department; std::cout << "专业:\t\t"; std::cin >> profession; std::cout << "职务:\t\t"; std::cin >> title; return 0; } #endif // TEACHER_H_INCLUDED administrator.h 行政人员: #ifndef ADMINISTRATOR_H_INCLUDED #define ADMINISTRATOR_H_INCLUDED #include"common.h" class ADMINISTRATOR: virtual public COMMON { protected: std::string politics; std::string position; static int administrator_sum; public: ADMINISTRATOR(std::string a = "huhu", bool b = 1, int c = 39, std::string d = "176", std::string e = "群众", std:: string f = "社会主义新青年"); ~ADMINISTRATOR(); static int get_administrator_sum(); virtual void show(); virtual void show_row(); virtual bool change(); std::string get_politics(){return politics;} std::string get_position(){return position;} }; int ADMINISTRATOR::administrator_sum = 0; int ADMINISTRATOR::get_administrator_sum() { return administrator_sum; } ADMINISTRATOR::ADMINISTRATOR(std::string a, bool b, int c, std::string d, std::string e, std::string f): COMMON(a,b,c,d), politics(e), position(f) { administrator_sum++; } ADMINISTRATOR::~ADMINISTRATOR() { administrator_sum--; } void ADMINISTRATOR::show() { std::cout << "行政人员:\n"; std::cout << "姓名:\t\t" << name << std::endl; std::cout << "姓别:\t\t"; if(sex) std::cout << "男\n"; else std::cout << "女\n"; std::cout << "年龄:\t\t" << age << std::endl; std::cout << "ID:\t\t" << id << std::endl; std::cout << "政治面貌:\t" << politics << std::endl; std::cout << "职称:\t\t" << position << std::endl; } void ADMINISTRATOR::show_row() { std::cout << std::left << std::setw(8) << name; if(sex) std::cout << std::left << std::setw(8) << "男"; else std::cout << std::left << std::setw(8) << "女"; std::cout << std::left << std::setw(8) << age; std::cout << std::left << std::setw(16) << id; std::cout << std::left << std::setw(16) << politics; std::cout << std::left << std::setw(16) << position; std::cout << std::endl; } bool ADMINISTRATOR::change() { std::cout << "姓名:\t\t" ; std::string new_name; std::cin >> new_name; for(unsigned int i = 0; i < new_name.length(); i++) { if(new_name[i] >= '0' && new_name[i] <= '9') { std::cout << "输入非法,输入任意键返回\n"; return 1; } } name = new_name; std::cout << "姓别:\t\t"; std::string a; std::cin >> a; if(sex) man_sum--; else woman_sum--; if(a == "男") sex = 1, man_sum++; else sex = 0, woman_sum++; std::cout << "年龄:\t\t"; std::cin >> age; std::cout << "政治面貌:\t"; std::cin >> politics; std::cout << "职称:\t\t"; std::cin >> position; return 0; } #endif // ADMINISTRATOR_H_INCLUDED tea&admi.h 教师及行政人员: #ifndef TEAADMI_H_INCLUDED #define TEAADMI_H_INCLUDED #include"teacher.h" #include"administrator.h" class TEAADMI: public TEACHER, public ADMINISTRATOR { private: static int teaadmi_sum; public: TEAADMI(std::string a = "maomao", bool b = 1, int c = 59, std::string d = "0", std::string e = "计算机与信息工程学院", std::string f = "计算机科学与技术", std::string g = "教师", std::string h = "群众", std:: string i = "社会主义新青年"); ~TEAADMI(); static int get_teaadmi_sum(); virtual void show(); virtual void show_row(); virtual bool change(); }; int TEAADMI::teaadmi_sum = 0; int TEAADMI::get_teaadmi_sum() { return teaadmi_sum; } TEAADMI::TEAADMI(std::string a, bool b, int c, std::string d, std::string e, std::string f, std::string g, std::string h, std::string i): COMMON(a,b,c,d), TEACHER(a,b,c,d,e,f,g), ADMINISTRATOR(a,b,c,d,h,i) { teaadmi_sum++; } TEAADMI::~TEAADMI() { teaadmi_sum--; } void TEAADMI::show() { std::cout << "教师及行政人员:\n"; std::cout << "姓名:\t\t" << name << std::endl; std::cout << "姓别:\t\t"; if(sex) std::cout << "男\n"; else std::cout << "女\n"; std::cout << "年龄:\t\t" << age << std::endl; std::cout << "ID:\t\t" << id << std::endl; std::cout << "院系:\t\t" << department << std::endl; std::cout << "专业:\t\t" << profession << std::endl; std::cout << "职务:\t\t" << title << std::endl; std::cout << "政治面貌:\t" << politics << std::endl; std::cout << "职称:\t\t" << position << std::endl; } void TEAADMI::show_row() { std::cout << std::left << std::setw(8) << name; if(sex) std::cout << std::left << std::setw(8) << "男"; else std::cout << std::left << std::setw(8) << "女"; std::cout << std::left << std::setw(8) << age; std::cout << std::left << std::setw(16) << id; std::cout << std::left << std::setw(16) << department; std::cout << std::left << std::setw(16) << profession; std::cout << std::left << std::setw(16) << title; std::cout << std::left << std::setw(16) << politics; std::cout << std::left << std::setw(16) << position; std::cout << std::endl; } bool TEAADMI::change() { std::cout << "姓名:\t\t" ; std::string new_name; std::cin >> new_name; for(unsigned int i = 0; i < new_name.length(); i++) { if(new_name[i] >= '0' && new_name[i] <= '9') { std::cout << "输入非法,输入任意键返回\n"; return 1; } } name = new_name; std::cout << "姓别:\t\t"; std::string a; std::cin >> a; if(sex) man_sum--; else woman_sum--; if(a == "男") sex = 1, man_sum++; else sex = 0, woman_sum++; std::cout << "年龄:\t\t"; std::cin >> age; std::cout << "院系:\t\t"; std::cin >> department; std::cout << "专业:\t\t"; std::cin >> profession; std::cout << "职务:\t\t"; std::cin >> title; std::cout << "政治面貌:\t"; std::cin >> politics; std::cout << "职称:\t\t"; std::cin >> position; return 0; } #endif // TEA&ADMI_H_INCLUDED interface.h 界面: #ifndef INTERFACE_H_INCLUDED #define INTERFACE_H_INCLUDED #include"teacher.h" #include"tester.h" #include"administrator.h" #include"tea&admi.h" #include<stdio.h> #include<stdlib.h> #include<conio.h> /*----------------函数声明-------------------*/ void interface_login(); //初始界面 void interface_Manager(); //管理者界面 void staff_list(); //管理者清单 #include"myfun.h" /*----------------函数定义-------------------*/ void interface_Manager() //管理界面 { int n=1; while(n) { system("cls"); std::cout << "------------欢迎来到只有神知道的领域 o(*≧▽≦)ツ----------\n"; std::cout << "-----------------------------------------------------------\n"; std::cout << "-----------------------------------------------------------\n"; std::cout << "------------- 输入1 添加信息 -------------\n"; std::cout << "------------- 输入2 查询信息 -------------\n"; std::cout << "------------- 输入3 浏览信息 -------------\n"; std::cout << "------------- 输入4 修改信息 -------------\n"; std::cout << "------------- 输入5 删除信息 -------------\n"; std::cout << "------------- 输入6 统计信息 -------------\n"; std::cout << "------------- 输入0 返回上一级 -------------\n"; std::cout << "-----------------------------------------------------------\n"; std::cout << "-----------------------------------------------------------\n"; std::cin >> n; switch(n) { case 1:Add_information();break; case 2: { int a = 1; if(!Query_information()) break; while(a) { std::cout << "输入1 修改信息\n"; std::cout << "输入2 删除信息\n"; std::cout << "输入0 返回上一级\n"; std::cin >> a; switch(a) { case 1:Edit_information(); a = 0; break; case 2:Delete_information(); a= 0; break; } } break; } case 3: { int a=1; while(a) { Browse_information(); std::cout << "输入1 修改信息\n"; std::cout << "输入2 删除信息\n"; std::cout << "输入0 返回上一级\n"; std::cin >> a; switch(a) { case 1:Edit_information(); break; case 2:Delete_information(); break; } } break; } case 4:Edit_information(); break; case 5:Delete_information(); break; case 6:count_information(); break; } } } void interface_login() //登入界面 { int n=1; while(n) { system("cls"); std::cout << "----------欢迎进入高校人员信息管理系统 o(*≧▽≦)ツ--------\n"; std::cout << "-----------------------------------------------------------\n"; std::cout << "-----------------------------------------------------------\n"; std::cout << "------------- 输入1 管理员账号登入 -------------\n"; std::cout << "------------- 输入2 查询信息 -------------\n"; std::cout << "------------- 输入3 浏览信息 -------------\n"; std::cout << "------------- 输入4 统计信息 -------------\n"; std::cout << "------------- 输入5 观看制作信息 -------------\n"; std::cout << "------------- 输入0 关闭系统 -------------\n"; std::cout << "-----------------------------------------------------------\n"; std::cout << "-----------------------------------------------------------\n"; std::cin >> n; switch(n) { case 1:login(); break; case 2:if(Query_information()) std::cout << "输入任意键,返回上一级\n", getch(); break; case 3:Browse_information(); std::cout << "输入任意键,返回上一级\n"; getch(); break; case 4:count_information(); break; case 5:staff_list(); break; } } } void staff_list() //制作人员名单 { system("cls"); std::cout << "-----------------------------------------------------------\n"; std::cout << "-----------------------------------------------------------\n"; std::cout << "--------------Include the following members----------------\n"; std::cout << "-------------- wzy ----------------\n"; std::cout << "-------------- ToRe ----------------\n"; std::cout << "-----------------------------------------------------------\n"; std::cout << "-----------------------------------------------------------\n\n\n"; std::cout << "\n输入任意键返回主菜单…\n"; getch(); } #endif // INTERFACE_H_INCLUDED myfun.h 主要功能实现: #ifndef MYFUN_H_INCLUDED #define MYFUN_H_INCLUDED #include<vector> #include<map> #include<fstream> /*----------------成员声明-------------------*/ std::multimap<std::string, COMMON *> sear; std::vector<TESTER*> tester; std::vector<TEACHER*> teacher; std::vector<ADMINISTRATOR*> administrator; std::vector<TEAADMI*> teaadmi; /*----------------函数声明-------------------*/ void Information_load(); //信息加载 void room_delete(); //释放空间 void login(); //登入函数 void Add_information(); //添加信息 bool Query_information(); //显示查询信息 void Browse_information(); //浏览信息 void Edit_information(); //修改信息 void Delete_information(); //删除信息 void count_information(); //统计信息 /*----------------函数定义-------------------*/ void Information_load() //信息加载 { std::ifstream in; in.open("实验员.txt", std::ios::in); std::string name, id; int age; bool sex; while(in >> name) { std::string laboratory, title; in >> sex >> age >> id >> laboratory >> title; TESTER *t = new TESTER(name,sex,age,id,laboratory,title); tester.push_back(t); sear.insert(make_pair(name, t)); sear.insert(make_pair(id, t)); } in.close(); in.open("教师.txt", std::ios::in); while(in >> name) { std::string department, profession, title; in >> sex >> age >> id >> department >> profession >> title; TEACHER *t = new TEACHER(name,sex,age,id,department,profession,title); teacher.push_back(t); sear.insert(make_pair(name, t)); sear.insert(make_pair(id, t)); } in.close(); in.open("行政人员.txt", std::ios::in); while(in >> name) { std::string politics, position; in >> sex >> age >> id >> politics >> position; ADMINISTRATOR *t = new ADMINISTRATOR(name,sex,age,id,politics,position); administrator.push_back(t); sear.insert(make_pair(name, t)); sear.insert(make_pair(id, t)); } in.close(); in.open("教师&行政人员.txt", std::ios::in); while(in >> name) { std::string department, profession, title, politics, position; in >> sex >> age >> id >> department >> profession >> title >> politics >> position; TEAADMI *t = new TEAADMI(name,sex,age,id,department,profession,title,politics,position); teaadmi.push_back(t); sear.insert(make_pair(name, t)); sear.insert(make_pair(id, t)); } } void room_delete() //释放空间 { for(auto iter:tester) delete iter; for(auto iter:teacher) delete iter; for(auto iter:administrator) delete iter; for(auto iter:teaadmi) delete iter; } void login() //登入函数 { std::string com; system("cls"); std::cout << "请输入密码\n"; getchar(); std::getline(std::cin,com); if(com == "bokuwasinnsekainokamitonaru") interface_Manager(); else { std::cout << "密码错误,输入任意键返回上一级\n"; getch(); } } void Add_information()//添加信息 { system("cls"); std::cout << "请输入添加类型\n1:实验员\t2:教师\t\t3:行政人员\t4:教师及行政人员\n"; int flag; std::cin >> flag; std::string name, se, id; int age; bool sex = 0; std::cout << "ID:\t\t"; std::cin >> id; for(unsigned int i = 0; i < id.length(); i++) { if(id[i] < '0' || id[i] > '9') { std::cout << "输入非法,输入任意键返回\n"; getch(); return; } } std::multimap<std::string, COMMON *>::iterator beg, en; beg = sear.lower_bound(id); en = sear.upper_bound(id); if(beg != en) { std::cout << "此ID已存在,输入任意键返回\n"; getch(); return; } std::cout << "姓名:\t\t"; std::cin >> name; for(unsigned int i = 0; i < name.length(); i++) { if(name[i] >= '0' && name[i] <= '9') { std::cout << "输入非法,输入任意键返回\n"; getch(); return; } } std::cout << "性别:\t\t"; std::cin >> se; if(se == "男") sex = 1; std::cout << "年龄:\t\t"; std::cin >> age; if(flag == 1) { std::string laboratory, title; std::cout << "实验室名称:\t"; std::cin >> laboratory; std::cout << "职务:\t\t"; std::cin >> title; TESTER *t = new TESTER(name,sex,age,id,laboratory,title); tester.push_back(t); sear.insert(make_pair(name, t)); sear.insert(make_pair(id, t)); std::ofstream out; out.open("实验员.txt", std::ios::app); out << name << " " << sex << " " << age << " " << id << " "; out << laboratory << " " << title << std::endl; out.close(); } if(flag == 2) { std::string department, profession, title; std::cout << "院系:\t\t"; std::cin >> department; std::cout << "专业:\t\t"; std::cin >> profession; std::cout << "职务:\t\t"; std::cin >> title; TEACHER *t = new TEACHER(name,sex,age,id,department,profession,title); teacher.push_back(t); sear.insert(make_pair(name, t)); sear.insert(make_pair(id, t)); std::ofstream out; out.open("教师.txt", std::ios::app); out << name << " " << sex << " " << age << " " << id << " "; out << department << " " << profession << " " << title << std::endl; out.close(); } if(flag == 3) { std::string politics, position; std::cout << "政治面貌:\t"; std::cin >> politics; std::cout << "职称:\t\t"; std::cin >> position; ADMINISTRATOR *t = new ADMINISTRATOR(name,sex,age,id,politics,position); administrator.push_back(t); sear.insert(make_pair(name, t)); sear.insert(make_pair(id, t)); std::ofstream out; out.open("行政人员.txt", std::ios::app); out << name << " " << sex << " " << age << " " << id << " "; out << politics << " " << position << std::endl; out.close(); } if(flag == 4) { std::string department, profession, title, politics, position; std::cout << "院系:\t\t"; std::cin >> department; std::cout << "专业:\t\t"; std::cin >> profession; std::cout << "职务:\t\t"; std::cin >> title; std::cout << "政治面貌:\t"; std::cin >> politics; std::cout << "职称:\t\t"; std::cin >> position; TEAADMI *t = new TEAADMI(name,sex,age,id,department,profession,title,politics,position); teaadmi.push_back(t); sear.insert(make_pair(name, t)); sear.insert(make_pair(id, t)); std::ofstream out; out.open("教师&行政人员.txt", std::ios::app); out << name << " " << sex << " " << age << " " << id << " "; out << department << " " << profession << " " << title << " "; out << politics << " " << position << std::endl; out.close(); } std::cout << "注册成功,输入任意键返回\n"; getch(); } void Delete_information() //删除信息 { std::cout << "输入目标ID以确认\n"; std::string aid; std::cin >> aid; for(unsigned int i = 0; i < aid.length(); i++) { if(aid[i] < '0' || aid[i] > '9') { std::cout << "输入非法,输入任意键返回\n"; getch(); return; } } std::multimap<std::string, COMMON *>::iterator beg, en, iter; beg = sear.lower_bound(aid); en = sear.upper_bound(aid); if(beg == en) { std::cout << "目标不存在,输入任意键返回\n"; getch(); return; } std::string aid_name = beg -> second -> get_name(); sear.erase(beg); beg = sear.lower_bound(aid_name); en = sear.upper_bound(aid_name); for(iter = beg; iter != en; ++iter) if(iter -> second -> get_id() == aid) {sear.erase(iter); break;} bool flag = 0; std::ofstream out; out.open("实验员.txt", std::ios::out); for(std::vector<TESTER*>::iterator it = tester.begin(); it != tester.end();) { if((*it) -> get_id() == aid){flag = 1; delete (*it); it = tester.erase(it); continue;} out << (*it) -> get_name() << " " << (*it) -> get_sex() << " "; out << (*it) -> get_age() << " " << (*it) -> get_id() << " "; out << (*it) -> get_laboratory() << " " << (*it) -> get_title() << std::endl; ++it; } out.close(); if(flag) {std::cout << "删除成功,输入任意键返回\n"; getch(); return;} out.open("教师.txt", std::ios::out); for(std::vector<TEACHER*>::iterator it = teacher.begin(); it != teacher.end();) { if((*it) -> get_id() == aid){flag = 1; delete (*it); it = teacher.erase(it); continue;} out << (*it) -> get_name() << " " << (*it) -> get_sex() << " "; out << (*it) -> get_age() << " " << (*it) -> get_id() << " "; out << (*it) -> get_department() << " " << (*it) -> get_profession() << " " << (*it) -> get_title() << std::endl; it++; } out.close(); if(flag) {std::cout << "删除成功,输入任意键返回\n"; getch(); return;} out.open("行政人员.txt", std::ios::out); for(std::vector<ADMINISTRATOR*>::iterator it = administrator.begin(); it != administrator.end();) { if((*it) -> get_id() == aid){flag = 1; delete (*it); it = administrator.erase(it); continue;} out << (*it) -> get_name() << " " << (*it) -> get_sex() << " "; out << (*it) -> get_age() << " " << (*it) -> get_id() << " "; out << (*it) -> get_politics() << " " << (*it) -> get_position() << std::endl; it++; } out.close(); if(flag) {std::cout << "删除成功,输入任意键返回\n"; getch(); return;} out.open("教师&行政人员.txt", std::ios::out); for(std::vector<TEAADMI*>::iterator it = teaadmi.begin(); it != teaadmi.end();) { if((*it) -> get_id() == aid){flag = 1; delete (*it); it = teaadmi.erase(it); continue;} out << (*it) -> get_name() << " " << (*it) -> get_sex() << " "; out << (*it) -> get_age() << " " << (*it) -> get_id() << " "; out << (*it) -> get_department() << " " << (*it) -> get_profession() << " " << (*it) -> get_title() << " "; out << (*it) -> get_politics() << " " << (*it) -> get_position() << std::endl; ++it; } out.close(); std::cout << "删除成功,输入任意键返回\n"; getch(); } void Edit_information() //修改信息 { std::cout << "输入目标ID以确认\n"; std::string aid; std::cin >> aid; for(unsigned int i = 0; i < aid.length(); i++) { if(aid[i] < '0' || aid[i] > '9') { std::cout << "输入非法,输入任意键返回\n"; getch(); return; } } std::multimap<std::string, COMMON *>::iterator beg, en, iter; beg = sear.lower_bound(aid); en = sear.upper_bound(aid); if(beg == en) { std::cout << "目标不存在,输入任意键返回\n"; getch(); return; } system("cls"); bool flag = 0; std::ofstream out; out.open("实验员.txt", std::ios::out); for(auto iter:tester) { if(iter -> get_id() == aid) { iter -> show(), std::cout << "\n\n根据提示输入修改信息\n\n"; while(iter -> change()) { system("cls"); iter -> show(); std::cout << "输入非法,请重新输入\n"; } flag = 1; } out << iter -> get_name() << " " << iter -> get_sex() << " "; out << iter -> get_age() << " " << iter -> get_id() << " "; out << iter -> get_laboratory() << " " << iter -> get_title() << std::endl; } out.close(); if(flag) {std::cout << "修改成功,输入任意键返回\n"; getch(); return;} out.open("教师.txt", std::ios::out); for(auto iter:teacher) { if(iter -> get_id() == aid) { iter -> show(), std::cout << "\n\n根据提示输入修改信息\n\n"; while(iter -> change()) { system("cls"); iter -> show(); std::cout << "输入非法,请重新输入\n"; } flag = 1; } out << iter -> get_name() << " " << iter -> get_sex() << " "; out << iter -> get_age() << " " << iter -> get_id() << " "; out << iter -> get_department() << " " << iter -> get_profession() << " " << iter -> get_title() << std::endl; } out.close(); if(flag) {std::cout << "修改成功,输入任意键返回\n"; getch(); return;} out.open("行政人员.txt", std::ios::out); for(auto iter:administrator) { if(iter -> get_id() == aid) { iter -> show(), std::cout << "\n\n根据提示输入修改信息\n\n"; while(iter -> change()) { system("cls"); iter -> show(); std::cout << "输入非法,请重新输入\n"; } flag = 1; } out << iter -> get_name() << " " << iter -> get_sex() << " "; out << iter -> get_age() << " " << iter -> get_id() << " "; out << iter -> get_politics() << " " << iter -> get_position() << std::endl; } out.close(); if(flag) {std::cout << "修改成功,输入任意键返回\n"; getch(); return;} out.open("教师&行政人员.txt", std::ios::out); for(auto iter:teaadmi) { if(iter -> get_id() == aid) { iter -> show(), std::cout << "\n\n根据提示输入修改信息\n\n"; while(iter -> change()) { system("cls"); iter -> show(); std::cout << "输入非法,请重新输入\n"; } flag = 1; } out << iter -> get_name() << " " << iter -> get_sex() << " "; out << iter -> get_age() << " " << iter -> get_id() << " "; out << iter -> get_department() << " " << iter -> get_profession() << " " << iter -> get_title() << " "; out << iter -> get_politics() << " " << iter -> get_position() << std::endl; } out.close(); std::cout << "修改成功,输入任意键返回\n"; getch(); } bool Query_information() //查询函数 { system("cls"); std::cout << "输入目标姓名或ID以查询\n"; std::string aid; std::cin >> aid; std::multimap<std::string, COMMON *>::iterator beg, en, iter; beg = sear.lower_bound(aid); en = sear.upper_bound(aid); if(beg == en) { std::cout << "查询结果为空,输入任意键返回\n"; getch(); return 0; } for(iter = beg; iter != en; ++iter) { iter -> second -> show(); std::cout << std::endl; } return 1; } void Browse_information() //浏览函数 { system("cls"); std::cout << "-------------------实验员-------------------\n"; std::cout << "姓名\t" << "性别\t" << "年龄\t" << "ID\t\t" << "实验室名称\t" << "职务\n"; for(auto iter:tester) iter -> show_row(); std::cout << "\n------------------行政人员------------------\n"; std::cout << "姓名\t" << "性别\t" << "年龄\t" << "ID\t\t" << "政治面貌\t" << "职称\n"; for(auto iter:administrator) iter -> show_row(); std::cout << "\n--------------------教师--------------------\n"; std::cout << "姓名\t" << "性别\t" << "年龄\t" << "ID\t\t" << "院系\t\t" << "专业\t\t" << "职务\n"; for(auto iter:teacher) iter -> show_row(); std::cout << "\n-----------------行政人员&教师--------------\n"; std::cout << "姓名\t" << "性别\t" << "年龄\t" << "ID\t\t" << "政治面貌\t" << "职称\t\t" << "院系\t\t" << "专业\t\t" << "职务\n"; for(auto iter:teaadmi) iter -> show_row(); } void count_information() //统计信息 { system("cls"); std::cout << "员工总人数:\t\t" << COMMON::get_person_sum() << std::endl; std::cout << "男性人数:\t\t" << COMMON::get_man_sum() << std::endl; std::cout << "女性人数:\t\t" << COMMON::get_woman_sum() << std::endl; std::cout << "教师人数:\t\t" << TEACHER::get_teacher_sum() << std::endl; std::cout << "实验员人数:\t\t" << TESTER::get_tester_sum() << std::endl; std::cout << "行政管理人员人数:\t" << ADMINISTRATOR::get_administrator_sum() << std::endl; std::cout << "行政管理人员&教师人数:\t" << TEAADMI::get_teaadmi_sum() << std::endl; std::cout << "\n\n输入任意键返回上一级\n"; getch(); } #endif // MYFUN_H_INCLUDED main.cpp 主函数: #include"interface.h" int main() { Information_load(); //加载信息 interface_login(); //首界面 room_delete(); //释放空间 // count_information(); return 0; }
如何实现vector容器存储类但是提示Stack overflew?
C++刚入门 不太会,请各位大神帮忙查一下这个错误是为什么,真的万分感谢!!! 设计一个CMyClass,它仅包含一个int类型的成员变量m_nValue,该类能够自动实现记录添加新类到Vector容器中,不需要类的用户再做任何特别处理的情况下,实现用一个简单的容器中存储一个类的所有实例。 但是在编译的过程中出现了![图片说明](https://img-ask.csdn.net/upload/201812/31/1546223044_726574.jpg)这个报错。 最终程序的正确输出结果应该是: ``` The first end: 100 1 0 10 The second end: 100 1 0 10 1000 The third end: 100 1 0 ``` ``` #include "pch.h" #include <iostream> #include <vector> #include <iterator> #include <algorithm> using namespace std; class CMyClass { public: int m_nValue; public: static vector<CMyClass>member; CMyClass(); CMyClass(int value); ~CMyClass(); static void ShowList(); friend ostream & operator<<(ostream & output, const CMyClass & temp); }; std::vector<CMyClass> CMyClass::member; CMyClass::CMyClass() { m_nValue = 0; member.push_back(*this); } CMyClass::CMyClass(int value) { m_nValue = value; member.push_back(*this); } CMyClass::~CMyClass() { member.pop_back(); } void CMyClass::ShowList() { //vector<CMyClass>::iterator it; //for (it = member.begin(); it != member.end(); it++); for(int i=0;i<member.size();i++) { cout << member.at(i) << endl; } } ostream & operator<<(ostream & output, const CMyClass & temp) { output << temp.m_nValue; return output; } int main() { CMyClass a(100); CMyClass b(1); CMyClass c; CMyClass *d = new CMyClass; *d = 10; cout << "The first end: " << endl; CMyClass::ShowList(); if (1) { CMyClass e(1000); cout << "The second end: " << endl; CMyClass::ShowList(); } delete d; cout << "The third end: " << endl; CMyClass::ShowList(); return 0; } ```
请问容器设计的问题....
如果有一个映射比如,a对应一个数组,b对应一个数组。。。。如果用二维vector不能设置a,b的值啊 请问应该怎么办?
关于C++类调用有参构造函数的问题
``` String(string s) { str.resize(s.size()); for(unsigned int i=0;i<s.size();++i) str[i]=s[i]; } ``` 在一道题目中要求设计一个类里面用向量实现类的一些功能 str是类String中的vector<char> 当在主函数中调试时输入: ``` String m="abc"; ``` 的时候编译器就报错: main.cpp|5|error: conversion from 'const char [4]' to non-scalar type 'String' requested| 请问这个该怎么改,是哪里有问题? 谢谢各位大佬
C++程序设计课程上机实验题
实验一:向量和输入输出 (设计性实验,2学时) 1.实验目的 (1)复习结构化程序设计; (2)掌握C++的常见I/O操作和向量类的使用。 2. 实验内容 (1)验证vector的各个操作。 (2)从计算机终端读一组数据到vector对象,计算机并输出每对相邻元素的和,如果读入的个数为奇数,则提示用户最后一个元素没有求和,并输出其值。然后修改程序:头尾元素两两配对(第一个和最后一个,第二个和倒数第二个,以此类推),计算每对元素得和,并输出。(设置一个文件,存入若干行整数,完成以上功能)。 (3)读入一段文本到vector对象,每个单词存储为vector中的一个元素,把vector对象中的每一个单词转换为大写字母,输出vector对象中转化后的元素,每个单词为一行输出。(设置一个文件,存入若干行单词,完成以上功能)。 (4)下面的程序是否合法,如果不合法,如何更正? vector<int> ivec; Ievc[0]=42;
关于《C++程序设计原理与实践》第3章例子的一个问题
本人菜鸟,现正在学习C++。《C++程序设计原理与实践》第3章有一个例子,代码如下: #include<iostream> #include<string> #include<vector> #include <algorithm> #include<cmath> using namespace std; inline void keep_window_open(){ char ch; cin >> ch; } int main() //C++ Programs start by executing the function main { cout << "Please enter a floating-point value:"; double n; cin >> n; cout << "n==" << n << "\nn+1==" << n + 1 << "\nthree times n==" << 3 * n << "\ntwice n==" << n + n << "\nhalf of n==" << n / 2 << "\nsquared root of n==" << sqrt(n) << endl; } 我执行后发现输入数字后再按回车会退出程序窗口。不知道为什么。请各位大神不吝赐教!谢谢!
急 c++课程设计排序问题。要求如下:
二、 课程设计的主要内容 功能描述:某实验室对研究生每天的科研时间进行管理,研究生每天进入实验室时记录其到达时间,离开实验室时记录其离开时间。两个时间之间的时间段作为其当天的科研工作时间。请你为其设计一个考勤管理系统,该系统需要提供下列功能: (1) 研究生信息录入功能,提示用户逐项输入研究生信息(时、分、秒分三次逐项输入),并检查输入信息的合法性(如时、分、秒的取值范围),同时以分为单位计算每位同学的科研时间; (2) 考勤信息浏览功能,显示所有研究生的考勤情况;例如: ---------------------------------------------------------------------------------------------------------------------- 学号 姓名 到达时间 离开时间 科研时间 排名 ---------------------------------------------------------------------------------------------------------------------- 201101 张三 08:00:00 17:12:00 492 3 201102 李四 09:10:20 17:30:20 500 2 201103 王五 08: 10:20 16:10:20 540 1 ---------------------------------------------------------------------------------------------------------------------- (3) 排序功能,按科研时间长短进行排序并显示 提示: (1) 使用数组、结构体 (2) 使用排序算法 ``` // 课程设计.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include "iostream" #include "string" #include "iomanip" #include "vector" #include<fstream> #include<algorithm> #include<iomanip> using namespace std; class student{ protected: string name;//姓名 string studentId;//学号 int hour;//签到小时 int minute;//签到分钟 int second;//签到秒数 int chour;//签退小时 int cminute;//签退分钟 int csecond;//签退秒数 int researchTime[100];//科研时间 int ranking;//排名 public: /*构造函数 初始化变量*/ student(){ name = ""; studentId = ""; hour = 0; minute = 0; second = 0; chour = 0; cminute = 0; csecond = 0; ranking = 0; researchTime[100] = 0; } bool set_name(string); bool set_studentId(string); bool set_hour(int); bool set_minute(int); bool set_second(int); bool set_chour(int); bool set_cminute(int); bool set_csecond(int); bool set_researchTime(int); bool set_ranking(int); string get_name(); string get_studentId(); int get_hour(); int get_minute(); int get_second(); int get_chour(); int get_cminute(); int get_csecond(); int get_researchTime(); int get_ranking(); }; bool student::set_studentId(string ID){ studentId = ID; return true; } bool student::set_name(string na){ name = na; return true; } bool student::set_hour(int ho){ hour = ho; return true; } bool student::set_minute(int mi){ minute = mi; return true; } bool student::set_second(int se){ second = se; return true; } bool student::set_chour(int cho){ chour = cho; return true; } bool student::set_cminute(int cmi){ cminute = cmi; return true; } bool student::set_csecond(int cse){ csecond = cse; return true; } bool student::set_researchTime(int res){ researchTime[10] = res; return true; } bool student::set_ranking(int ran){ ranking = ran; return true; } string student::get_studentId(){ return studentId; } string student::get_name(){ return name; } int student::get_hour(){ return hour; } int student::get_minute(){ return minute; } int student::get_second(){ return second; } int student::get_chour(){ return chour; } int student::get_cminute(){ return cminute; } int student::get_csecond(){ return csecond; } int student::get_researchTime(){ return researchTime[10]; } int student::get_ranking(){ return ranking; } void drow(){ cout << endl; cout << "********考勤统计********" << endl; cout << " " << "请输入相应字母进行操作!" << endl; cout << " " << "L:信息录入(Log in)" << endl; cout << " " << "O:输出(Output)" << endl; cout << " " << "E:退出(Exit)" << endl; cout << "************************" << endl; } student *Registration(){ student *temp; string info; int timeIn = NULL; temp = new student; cout << "你的学号" << endl; cin >> info; temp->set_studentId(info); cout << "你的姓名" << endl; cin >> info; temp->set_name(info); cout << "***到达时间(按提示依次录入时,分,秒)***" << endl; cout << "到达整点" << endl; cin >> timeIn; if (timeIn >= 0 && timeIn < 24){ temp->set_hour(timeIn); } else { cout << "输入有误,请重新输入" << endl; cin >> timeIn; temp->set_hour(timeIn); } cout << "到达分钟" << endl; cin >> timeIn; if (timeIn >= 0 && timeIn < 60){ temp->set_minute(timeIn); } else{ cout << "输入有误,请重新输入" << endl; cin >> timeIn; temp->set_minute(timeIn); } cout << "到达秒数" << endl; cin >> timeIn; if (timeIn >= 0 && timeIn < 60){ temp->set_second(timeIn); } else {cout << "输入有误,请重新输入" << endl; cin >> timeIn; temp->set_second(timeIn); } cout << "***离开时间(按提示依次录入时,分,秒)***" << endl; cout << "离开整点" << endl; cin >> timeIn; if (timeIn >= 0 && timeIn < 24){ temp->set_chour(timeIn); } else { cout << "输入有误,请重新输入" << endl; cin >> timeIn; temp->set_chour(timeIn); } cout << "离开分钟" << endl; cin >> timeIn; if (timeIn >= 0 && timeIn < 60){ temp->set_cminute(timeIn); } else{ cout << "输入有误,请重新输入" << endl; cin >> timeIn; temp->set_cminute(timeIn); } cout << "离开秒数" << endl; cin >> timeIn; if (timeIn >= 0 && timeIn < 60){ temp->set_csecond(timeIn); } else { cout << "输入有误,请重新输入" << endl; cin >> timeIn; temp->set_csecond(timeIn); } cout << endl << "信息录入成功=^_^=" << endl; return temp; } void ResearchTime(student *temp){ int reschT = ((temp->get_chour()) * 60 + temp->get_cminute()) - ((temp->get_hour()) * 60 + temp->get_minute()) ; temp->set_researchTime(reschT); int i = 0; i += 1; temp->set_ranking(i); } void save(student *temp){ ofstream os;//文件操作 os.open("outfile.txt",ios::app); os << endl; os << setw(2) << "学生学号:" << temp->get_studentId() << endl; os << setw(2) << "学生姓名:" << temp->get_name() << endl; os << setw(2) << "签到时间:" << setw(2) << setfill('0') << temp->get_hour(); os << ":" << setw(2) << setfill('0') << temp->get_minute() << ":"; os << setw(2) << setfill('0') << temp->get_second() << endl; os << setw(2) << "签退时间:" << setw(2) << setfill('0') << temp->get_chour(); os << ":" << setw(2) << setfill('0') << temp->get_cminute() << ":"; os << setw(2) << setfill('0') << temp->get_csecond() << endl; os << setw(2) << "科研时间:" << temp->get_researchTime() << endl; os << setw(2) << "时间排名:" << temp->get_ranking() << endl; temp++; os.close(); } void read(){ filebuf *pbuf; ifstream is; long size; char *buffer; if (!is){ cout << "读取不到" << endl; } //采用二进制读取整个文件 is.open("outfile.txt", ios::binary); // 获取filestr对应buffer对象的指针 pbuf = is.rdbuf(); // 调用buffer对象方法获取文件大小 size = pbuf->pubseekoff(0, ios::end, ios::in); pbuf->pubseekpos(0, ios::in); // 分配内存空间 buffer = new char[size]; // 获取文件内容 pbuf->sgetn(buffer, size); is.close(); // 输出到标准输出 cout.write(buffer, size); delete[]buffer; } int _tmain(int argc, _TCHAR* argv[]) { student s; student *temp=NULL; int i = 1; char input = 'e'; input = 'i'; while (input != 'e'){ drow(); cin >> input; input = tolower(input);//大写转义为小写 switch (input) { case 'l': cout << "信息录入:" << endl; temp = Registration(); ResearchTime(temp); save(temp); break; case 'o': read(); cout << endl << "信息读取成功=^_^= ,按提示信息进行其他操作" << endl; break; case'e': cout << "谢谢使用,再见!" << endl; std::system("pause"); std::exit(0); break; default: cout << "输入有误" << endl; break; } } std::system("pause"); return 0; } ```
ftp服务器的问题c++语言
计网课程设计要做一个ftp服务器并用命令行进行连接和访问, 现在在连接的时候不知道为什么连接不上,服务器过一会儿就自动断开 ![图片说明](https://img-ask.csdn.net/upload/201906/25/1561448979_761798.png) 下面是代码 ``` #include<io.h> #include<string> #include<iostream> #include<vector> #include<thread> #include<WS2tcpip.h> #include<winsock2.h> #pragma comment(lib,"ws2_32.lib") #pragma warning(disable : 4996) int main() { WORD sockVersion = MAKEWORD(2, 2); WSADATA data; if (WSAStartup(sockVersion, &data) != 0) { std::cout << "WSAStartup error" << std::endl; return 0; } SOCKET serverSock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (INVALID_SOCKET == serverSock) { std::cout << "socket erroro" << std::endl; closesocket(serverSock); WSACleanup(); return 0; } sockaddr_in cmd_port; cmd_port.sin_family = AF_INET; cmd_port.sin_port = htons(21); inet_pton(AF_INET, "127.0.0.1", &cmd_port.sin_addr); if (bind(serverSock, (SOCKADDR*)& cmd_port, sizeof(SOCKADDR))) { std::cout << "bind error" << std::endl; closesocket(serverSock); WSACleanup(); return 0; } if (listen(serverSock, 5) == SOCKET_ERROR) { std::cout << "listen error" << std::endl; closesocket(serverSock); WSACleanup(); return 0; } SOCKET userSock;//用户端socket信息 sockaddr_in user_sockAddr;//用于accept函数,存放客户端的信息 int addrlen = sizeof(user_sockAddr); while (true) { std::cout << "waiting to be connected..." << std::endl; userSock = accept(serverSock, (SOCKADDR*)& user_sockAddr, &addrlen);//接受用户端请求,返回一个套接字 if (INVALID_SOCKET == userSock) { std::cout << "accept error." << std::endl; continue; } char user_ip[16]; inet_ntop(AF_INET, &user_sockAddr.sin_addr, user_ip, sizeof(user_ip)); std::cout << "接收到一个链接:" << user_ip << std::endl; } } ``` 望各位大触指教
几何图形遮挡的绘制问题,怎么使用C语言的程序编写设计的思想的代码的一个实现的方式
Problem Description huicpc0860 likes drawing,but not good at drawing.One day, he gets a software of drawing. The software provides a eraser B,you can consider it like a convex hull. Yet, the eraser can make your draw from black to white.Now give you a black convex hull A which you can consider like a drawing, and a white convex hull which is a eraser.Now, we only know the angle a between the eraser's moving direction and the x-axis,and I want to move the eraser the least distance to make the remaind part area of the drawing is K percent of the original's. Input First line is the number of soiled area A's vectors NA(3<=NA<=100).Follows NA lines, describes the convex polygon counterclockwise, each line has two decimal xi, yi ( -10000 ≤ xi, yi ≤ 10000) representatives one vector's coordinate. Then, another line is the number of soiled area B's vectors NB(3<=NB<=100).Follows NB lines, describes the convex polygon counterclockwise, each line has two decimal xi, yi ( -10000 ≤ xi, yi ≤ 10000) representatives one vector's coordinate. Lastest line has two decimal, a and K.a (0 ≤a< 360)is the direction's angle with x positive axis and K is the rate. Output Only one line for each case,the minimum distance D (retain four digitals after decimal point). If it's impossible to get,output -1. Sample Input 4 0 0 2 0 2 2 0 2 4 -2 0 -1 0 -1 1 -2 1 0 0.75 3 -2 -1 -1 0 -2 1 3 1 -1 2 0 1 1 180 0.5 Sample Output 2.0000 2.7071
不同图形旋转的阴影遮挡和旋转的问题,如何使用C语言的程序设计思想的原则和方法有效实现的呢?
Problem Description huicpc0860 likes drawing,but not good at drawing.One day, he gets a software of drawing. The software provides a eraser B,you can consider it like a convex hull. Yet, the eraser can make your draw from black to white.Now give you a black convex hull A which you can consider like a drawing, and a white convex hull which is a eraser.Now, we only know the angle a between the eraser's moving direction and the x-axis,and I want to move the eraser the least distance to make the remaind part area of the drawing is K percent of the original's. Input First line is the number of soiled area A's vectors NA(3<=NA<=100).Follows NA lines, describes the convex polygon counterclockwise, each line has two decimal xi, yi ( -10000 ≤ xi, yi ≤ 10000) representatives one vector's coordinate. Then, another line is the number of soiled area B's vectors NB(3<=NB<=100).Follows NB lines, describes the convex polygon counterclockwise, each line has two decimal xi, yi ( -10000 ≤ xi, yi ≤ 10000) representatives one vector's coordinate. Lastest line has two decimal, a and K.a (0 ≤a< 360)is the direction's angle with x positive axis and K is the rate. Output Only one line for each case,the minimum distance D (retain four digitals after decimal point). If it's impossible to get,output -1. Sample Input 4 0 0 2 0 2 2 0 2 4 -2 0 -1 0 -1 1 -2 1 0 0.75 3 -2 -1 -1 0 -2 1 3 1 -1 2 0 1 1 180 0.5 Sample Output 2.0000 2.7071
EDA数字钟秒钟sec的代码怎么设计
library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity cnt60 is port(clk,clr,rst:in std_logic; sec1:in std_logic_vector(3 downto 0); sec0:in std_logic_vector(3 downto 0); sec11:out std_logic_vector(3 downto 0); sec00:out std_logic_vector(3 downto 0); co:out std_logic); end cnt60; architecture behav of cnt60 is signal cnt0:std_logic_vector(3 downto 0); signal cnt1:std_logic_vector(2 downto 0); signal clk1:std_logic; begin a:process(clk,clr,rst) begin if rst='1'then cnt0<="0000"; elsif(clk'event and clk='1')and clr='1'then if cnt0="1001"then cnt0<="0000"; clk1<='1'; else cnt0<=cnt0+1; clk1<='0'; end if; end if; end process a; b:process(rst,clr,clk1) begin if rst='1'then cnt1<="000"; elsif(clk1'event and clk1='1')and clr='1'then if cnt1="101"then cnt1<="000"; else cnt1<=cnt1+1; end if; end if; end process b; c:process(clk,clk1) begin if clk'event and clk='1'then if cnt1="101" and cnt0="1001"then co<='1'; else co<='0'; end if; end if; end process c; co(4 downto 0)<=cnt0; co(7 downto 4)<=cnt1; end behav; 求各位大神帮忙看下这代码错在哪里,小白求
平面镜的光路反射的计算问题,怎么运用C语言程序编写的代码的形式去设计的?
Problem Description Dr. Evil has contracted your valuable services to build for him the world's most powerful "laser". Of course before you spend one billion dollars building the thing, you want to run some simulations first to make sure everything will work as designed. For this phase of the project, you will be simulating part of the aiming system which uses mirrors and other optics to change the direction of the laser beam. The simulation consists of a flat square table with mirrors, beam splitters, and beam detectors arranged on the tabletop, and with each object represented by a one dimensional line segment. The list below describes each of the object types in detail: mirror : A mirror object will reflect any laser beam striking its surface. The reflected beam leaves at the same angle of incidence as the incoming beam. Note that both sides of a mirror object are reflective. detector : A detector is an opaque object which absorbs any laser beam striking it. The simulation must also keep track of which detectors are struck by a laser for program output purposes. Note that a laser beam strike on either side of a detector counts as a "hit". splitter : When a laser beam strikes a splitter, it divides into two beams. One of the new beams will reflect from the splitter surface (as with a mirror), and the other beam will pass through the splitter without changing direction. A splitter will function the same way regardless which side of it is struck by a laser beam. See the figures below for examples of a laser beam's interaction with each of the possible object types: For each simulation, a single laser beam enters the tabletop area. The program must compute the path taken by the laser beam (including secondary beams due to splitters), and it must determine which detectors are struck by a laser beam. You can make the following assumptions in the program: 1. The tabletop surface is a 100 by 100 square, and unless otherwise specified all coordinates in the program's input are given as integers within the tabletop area (i.e. between 0 and 100 inclusive). 2. There will be no overlaps between the line 2. segment objects. 3. The laser which enters the tabletop area always starts from the edge of the table. 4. The simulation of each data set ends when all laser beams have either exited the table top area or have terminated at a detector. 5. For each data set there will be no more than 100 total reflections among all laser beams in that data set. 6. A laser beam will never intersect any object on a vertex and will never be collinear with an object's line segment. 7. Each data set will contain at least one detector object. Input Input to this problem will begin with a line containing a single integer N (1 ≤ N ≤ 100) indicating the number of data sets. Each data set consists of the following components: A single line with four numbers "x,y i,j" where x,y is a point along the table edge at which the laser beam enters, and i,j is a vector with integer components(-1024 ≤ i,j ≤ 1024) specifying the direction of the incoming laser beam, where i corresponds to the x-axis direction and j corresponds to the y-axis direction. A line with a single integer P (1 ≤ P ≤ 100) giving the total number of objects in this data set. A series of P lines, each representing one object, with the first line describing object 1, the second line describing object 2, and so on. Each line begins with a single letter specifying the object type where a "M" indicates a mirror object, "S" a splitter, and "D" a detector. This is followed by two coordinate pairs of the form "x,y", specifying the two end points of the object's line segment. Output For each data set in the input, output the heading "DATA SET #k" where k is 1 for the first data set, 2 for the second, etc. If in this data set none of the detector objects are struck by any laser beams, output the message "NO BEAMS DETECTED". Otherwise, output the object number, one per line, of each detector struck by a laser beam. The list of detectors should be sorted by their object numbers and output in ascending order. If a detector is struck by more than one laser beam, it should only be listed once in the output. Sample Input 1 50,100 0,-1 6 D 0,40 20,20 M 40,20 60,40 D 80,20 100,40 D 0,70 20,90 S 40,90 60,70 D 80,90 100,70 Sample Output DATA SET #1 1 6
opencv代码问题,为什么会这么多错误
这段代码为什么会有这么多错误,怎么修改 #include "opencv2/imgproc/imgproc.hpp" #include "opencv2/highgui/highgui.hpp" #include "opencv2/features2d/features2d.hpp" #include <stdlib.h> #include <stdio.h> using namespace cv; using namespace std; // 计算图像矩 void cacMoments(cv::Mat src) { Mat srcGray; vector<vector<Point> > contours; vector<Vec4i> hierarchy; // 高斯滤波 GaussianBlur(src, src, Size(3, 3), 0.1, 0, BORDER_DEFAULT); // 灰度转换 cvtColor(src, srcGray, CV_RGB2GRAY); // 轮廓边界检测 findContours(srcGray, contours, hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE, Point(0, 0)); // 绘制边界 // drawContours(src, contours, -1, cvScalar(0,0,255)); printf("Number of contours: %d\n", (int)contours.size()); // 计算轮廓矩 vector<Moments> mu(contours.size()); for (int i = 0; i < (int)contours.size(); i++) { mu[i] = moments(contours[i], false); } // 分析矩计算图像相关特征 for (int i = 0; i < (int)contours.size(); i++) { // 面积 重心 边界轮廓长度 int area = mu[i].m00; int cx = mu[i].m10 / mu[i].m00; int cy = mu[i].m01 / mu[i].m00; int perimeter = arcLength(contours.at(i), true); // 椭圆 if (int(contours.at(i).size()) <= 5) { continue; } else { RotatedRect rRect = fitEllipse(contours.at(i)); double orientation = rRect.angle; double orientation_rads = orientation*3.1416 / 180; double majorAxis = rRect.size.height > rRect.size.width ? rRect.size.height : rRect.size.width; double minorAxis = rRect.size.height > rRect.size.width ? rRect.size.width : rRect.size.height; // 圆形度 离心率 周长 直径 double roundness = pow(perimeter, 2) / (2 * 3.1416*area); double eccentricity = sqrt(1 - pow(minorAxis / majorAxis, 2)); double ratio = (minorAxis / majorAxis) * 100; double diameter = sqrt((4 * area) / 3.1416); // 输出相关特征信息 printf("Area: %d\n", area); printf("Perimeter: %d\n", perimeter); printf("Major Axis: %.1f\n", majorAxis); printf("Minor Axis: %.1f\n", minorAxis); printf("Orientation: %.1f\n", orientation); printf("Roundness: %.1f\n", roundness); printf("Eccentricity: %.1f\n", eccentricity); printf("Ratio: %.1f\n", ratio); printf("Diameter: %.1f\n", diameter); printf("\n"); // 绘制矩形及椭圆 ellipse(src, rRect, cvScalar(0, 255, 0)); rectangle(src, boundingRect(contours.at(i)), cvScalar(0, 0, 255)); // 绘制相关坐标 //line(src, Point(cx-30, cy), Point(cx+30, cy), cvScalar(0,0,255)); //line(src, Point(cx, cy-30), Point(cx, cy+30), cvScalar(0,0,255)); // 绘制起始线 line(src, Point(cx, cy), Point((int)(cx + 30 * cos(orientation_rads)), (int)(cy + 30 * sin(orientation_rads))), cvScalar(255, 0, 0), 1); // 输出图像起始 char pChar[100]; sprintf(pChar, "Ori: %.0f", orientation); putText(src, pChar, Point(cx, cy), FONT_HERSHEY_SIMPLEX, 0.4, cvScalar(255)); } } cv::imshow("result", src); } int main() { cv::Mat srcImage = imread("1.png"); if (!srcImage.data) return -1; cv::imshow("srcImage", srcImage); // 计算轮廓矩 cacMoments(srcImage); cv::waitKey(0); return(0); } 严重性 代码 说明 项目 文件 行 禁止显示状态 错误(活动) 无法打开 源 文件 "opencv2/imgproc/imgproc.hpp" ConsoleApplication1 d:\基于视觉的副驾驶座儿童乘坐提醒系统设计程序文档20180417\阈值化处理\ConsoleApplication1\main.cpp 2 错误(活动) 无法打开 源 文件 "opencv2/highgui/highgui.hpp" ConsoleApplication1 d:\基于视觉的副驾驶座儿童乘坐提醒系统设计程序文档20180417\阈值化处理\ConsoleApplication1\main.cpp 3 错误(活动) 无法打开 源 文件 "opencv2/features2d/features2d.hpp" ConsoleApplication1 d:\基于视觉的副驾驶座儿童乘坐提醒系统设计程序文档20180417\阈值化处理\ConsoleApplication1\main.cpp 4 错误(活动) 名称必须是命名空间名 ConsoleApplication1 d:\基于视觉的副驾驶座儿童乘坐提醒系统设计程序文档20180417\阈值化处理\ConsoleApplication1\main.cpp 7 错误(活动) 不允许使用不完整的类型 ConsoleApplication1 d:\基于视觉的副驾驶座儿童乘坐提醒系统设计程序文档20180417\阈值化处理\ConsoleApplication1\main.cpp 10 错误(活动) 后面有“::”的名称一定是类名或命名空间名 ConsoleApplication1 d:\基于视觉的副驾驶座儿童乘坐提醒系统设计程序文档20180417\阈值化处理\ConsoleApplication1\main.cpp 10 错误(活动) 应输入“)” ConsoleApplication1 d:\基于视觉的副驾驶座儿童乘坐提醒系统设计程序文档20180417\阈值化处理\ConsoleApplication1\main.cpp 10 错误(活动) 应输入“;” ConsoleApplication1 d:\基于视觉的副驾驶座儿童乘坐提醒系统设计程序文档20180417\阈值化处理\ConsoleApplication1\main.cpp 11 错误(活动) 此声明没有存储类或类型说明符 ConsoleApplication1 d:\基于视觉的副驾驶座儿童乘坐提醒系统设计程序文档20180417\阈值化处理\ConsoleApplication1\main.cpp 18 错误(活动) 未定义标识符 "src" ConsoleApplication1 d:\基于视觉的副驾驶座儿童乘坐提醒系统设计程序文档20180417\阈值化处理\ConsoleApplication1\main.cpp 18 错误(活动) 应输入“)” ConsoleApplication1 d:\基于视觉的副驾驶座儿童乘坐提醒系统设计程序文档20180417\阈值化处理\ConsoleApplication1\main.cpp 18 错误(活动) 此声明没有存储类或类型说明符 ConsoleApplication1 d:\基于视觉的副驾驶座儿童乘坐提醒系统设计程序文档20180417\阈值化处理\ConsoleApplication1\main.cpp 20 错误(活动) 未定义标识符 "srcGray" ConsoleApplication1 d:\基于视觉的副驾驶座儿童乘坐提醒系统设计程序文档20180417\阈值化处理\ConsoleApplication1\main.cpp 20 错误(活动) 应输入“)” ConsoleApplication1 d:\基于视觉的副驾驶座儿童乘坐提醒系统设计程序文档20180417\阈值化处理\ConsoleApplication1\main.cpp 20 错误(活动) 此声明没有存储类或类型说明符 ConsoleApplication1 d:\基于视觉的副驾驶座儿童乘坐提醒系统设计程序文档20180417\阈值化处理\ConsoleApplication1\main.cpp 24 错误(活动) 应输入“)” ConsoleApplication1 d:\基于视觉的副驾驶座儿童乘坐提醒系统设计程序文档20180417\阈值化处理\ConsoleApplication1\main.cpp 24 错误(活动) vector 不是模板 ConsoleApplication1 d:\基于视觉的副驾驶座儿童乘坐提醒系统设计程序文档20180417\阈值化处理\ConsoleApplication1\main.cpp 26 错误(活动) 未定义标识符 "Moments" ConsoleApplication1 d:\基于视觉的副驾驶座儿童乘坐提醒系统设计程序文档20180417\阈值化处理\ConsoleApplication1\main.cpp 26 错误(活动) 未定义标识符 "contours" ConsoleApplication1 d:\基于视觉的副驾驶座儿童乘坐提醒系统设计程序文档20180417\阈值化处理\ConsoleApplication1\main.cpp 26 错误(活动) 应输入声明 ConsoleApplication1 d:\基于视觉的副驾驶座儿童乘坐提醒系统设计程序文档20180417\阈值化处理\ConsoleApplication1\main.cpp 27 错误(活动) 未定义标识符 "sqrt" ConsoleApplication1 d:\基于视觉的副驾驶座儿童乘坐提醒系统设计程序文档20180417\阈值化处理\ConsoleApplication1\main.cpp 55 错误(活动) 此声明没有存储类或类型说明符 ConsoleApplication1 d:\基于视觉的副驾驶座儿童乘坐提醒系统设计程序文档20180417\阈值化处理\ConsoleApplication1\main.cpp 57 错误(活动) 应输入“)” ConsoleApplication1 d:\基于视觉的副驾驶座儿童乘坐提醒系统设计程序文档20180417\阈值化处理\ConsoleApplication1\main.cpp 57 错误(活动) 此声明没有存储类或类型说明符 ConsoleApplication1 d:\基于视觉的副驾驶座儿童乘坐提醒系统设计程序文档20180417\阈值化处理\ConsoleApplication1\main.cpp 58 错误(活动) 应输入“)” ConsoleApplication1 d:\基于视觉的副驾驶座儿童乘坐提醒系统设计程序文档20180417\阈值化处理\ConsoleApplication1\main.cpp 58 错误(活动) 此声明没有存储类或类型说明符 ConsoleApplication1 d:\基于视觉的副驾驶座儿童乘坐提醒系统设计程序文档20180417\阈值化处理\ConsoleApplication1\main.cpp 59 错误(活动) 应输入“)” ConsoleApplication1 d:\基于视觉的副驾驶座儿童乘坐提醒系统设计程序文档20180417\阈值化处理\ConsoleApplication1\main.cpp 59 错误(活动) 此声明没有存储类或类型说明符 ConsoleApplication1 d:\基于视觉的副驾驶座儿童乘坐提醒系统设计程序文档20180417\阈值化处理\ConsoleApplication1\main.cpp 60 错误(活动) 应输入“)” ConsoleApplication1 d:\基于视觉的副驾驶座儿童乘坐提醒系统设计程序文档20180417\阈值化处理\ConsoleApplication1\main.cpp 60 错误(活动) 此声明没有存储类或类型说明符 ConsoleApplication1 d:\基于视觉的副驾驶座儿童乘坐提醒系统设计程序文档20180417\阈值化处理\ConsoleApplication1\main.cpp 61 错误(活动) 应输入“)” ConsoleApplication1 d:\基于视觉的副驾驶座儿童乘坐提醒系统设计程序文档20180417\阈值化处理\ConsoleApplication1\main.cpp 61 错误(活动) 此声明没有存储类或类型说明符 ConsoleApplication1 d:\基于视觉的副驾驶座儿童乘坐提醒系统设计程序文档20180417\阈值化处理\ConsoleApplication1\main.cpp 62 错误(活动) 应输入“)” ConsoleApplication1 d:\基于视觉的副驾驶座儿童乘坐提醒系统设计程序文档20180417\阈值化处理\ConsoleApplication1\main.cpp 62 错误(活动) 此声明没有存储类或类型说明符 ConsoleApplication1 d:\基于视觉的副驾驶座儿童乘坐提醒系统设计程序文档20180417\阈值化处理\ConsoleApplication1\main.cpp 63 错误(活动) 应输入“)” ConsoleApplication1 d:\基于视觉的副驾驶座儿童乘坐提醒系统设计程序文档20180417\阈值化处理\ConsoleApplication1\main.cpp 63 错误(活动) 此声明没有存储类或类型说明符 ConsoleApplication1 d:\基于视觉的副驾驶座儿童乘坐提醒系统设计程序文档20180417\阈值化处理\ConsoleApplication1\main.cpp 64 错误(活动) 应输入“)” ConsoleApplication1 d:\基于视觉的副驾驶座儿童乘坐提醒系统设计程序文档20180417\阈值化处理\ConsoleApplication1\main.cpp 64 错误(活动) 此声明没有存储类或类型说明符 ConsoleApplication1 d:\基于视觉的副驾驶座儿童乘坐提醒系统设计程序文档20180417\阈值化处理\ConsoleApplication1\main.cpp 65 错误(活动) 应输入“)” ConsoleApplication1 d:\基于视觉的副驾驶座儿童乘坐提醒系统设计程序文档20180417\阈值化处理\ConsoleApplication1\main.cpp 65 错误(活动) 此声明没有存储类或类型说明符 ConsoleApplication1 d:\基于视觉的副驾驶座儿童乘坐提醒系统设计程序文档20180417\阈值化处理\ConsoleApplication1\main.cpp 66 错误(活动) 此声明没有存储类或类型说明符 ConsoleApplication1 d:\基于视觉的副驾驶座儿童乘坐提醒系统设计程序文档20180417\阈值化处理\ConsoleApplication1\main.cpp 68 错误(活动) 未定义标识符 "src" ConsoleApplication1 d:\基于视觉的副驾驶座儿童乘坐提醒系统设计程序文档20180417\阈值化处理\ConsoleApplication1\main.cpp 68 错误(活动) 应输入“)” ConsoleApplication1 d:\基于视觉的副驾驶座儿童乘坐提醒系统设计程序文档20180417\阈值化处理\ConsoleApplication1\main.cpp 68 错误(活动) 此声明没有存储类或类型说明符 ConsoleApplication1 d:\基于视觉的副驾驶座儿童乘坐提醒系统设计程序文档20180417\阈值化处理\ConsoleApplication1\main.cpp 69 错误(活动) 未定义标识符 "src" ConsoleApplication1 d:\基于视觉的副驾驶座儿童乘坐提醒系统设计程序文档20180417\阈值化处理\ConsoleApplication1\main.cpp 69 错误(活动) 应输入“)” ConsoleApplication1 d:\基于视觉的副驾驶座儿童乘坐提醒系统设计程序文档20180417\阈值化处理\ConsoleApplication1\main.cpp 69 错误(活动) 此声明没有存储类或类型说明符 ConsoleApplication1 d:\基于视觉的副驾驶座儿童乘坐提醒系统设计程序文档20180417\阈值化处理\ConsoleApplication1\main.cpp 74 错误(活动) 未定义标识符 "src" ConsoleApplication1 d:\基于视觉的副驾驶座儿童乘坐提醒系统设计程序文档20180417\阈值化处理\ConsoleApplication1\main.cpp 74 错误(活动) 应输入“)” ConsoleApplication1 d:\基于视觉的副驾驶座儿童乘坐提醒系统设计程序文档20180417\阈值化处理\ConsoleApplication1\main.cpp 74 错误(活动) 此声明没有存储类或类型说明符 ConsoleApplication1 d:\基于视觉的副驾驶座儿童乘坐提醒系统设计程序文档20180417\阈值化处理\ConsoleApplication1\main.cpp 78 错误(活动) 应输入“)” ConsoleApplication1 d:\基于视觉的副驾驶座儿童乘坐提醒系统设计程序文档20180417\阈值化处理\ConsoleApplication1\main.cpp 78 错误(活动) 此声明没有存储类或类型说明符 ConsoleApplication1 d:\基于视觉的副驾驶座儿童乘坐提醒系统设计程序文档20180417\阈值化处理\ConsoleApplication1\main.cpp 79 错误(活动) 未定义标识符 "src" ConsoleApplication1 d:\基于视觉的副驾驶座儿童乘坐提醒系统设计程序文档20180417\阈值化处理\ConsoleApplication1\main.cpp 79 错误(活动) 应输入“)” ConsoleApplication1 d:\基于视觉的副驾驶座儿童乘坐提醒系统设计程序文档20180417\阈值化处理\ConsoleApplication1\main.cpp 79 错误(活动) 应输入声明 ConsoleApplication1 d:\基于视觉的副驾驶座儿童乘坐提醒系统设计程序文档20180417\阈值化处理\ConsoleApplication1\main.cpp 80 错误(活动) 应输入声明 ConsoleApplication1 d:\基于视觉的副驾驶座儿童乘坐提醒系统设计程序文档20180417\阈值化处理\ConsoleApplication1\main.cpp 83 错误 C1083 无法打开包括文件: “opencv2/imgproc/imgproc.hpp”: No such file or directory ConsoleApplication1 d:\基于视觉的副驾驶座儿童乘坐提醒系统设计程序文档20180417\阈值化处理\consoleapplication1\main.cpp 2
急急c++课程设计,关于考勤统计的,我完成大部分就只差排序了,求帮助完成排序。
二、 课程设计的主要内容 功能描述:某实验室对研究生每天的科研时间进行管理,研究生每天进入实验室时记录其到达时间,离开实验室时记录其离开时间。两个时间之间的时间段作为其当天的科研工作时间。请你为其设计一个考勤管理系统,该系统需要提供下列功能: (1) 研究生信息录入功能,提示用户逐项输入研究生信息(时、分、秒分三次逐项输入),并检查输入信息的合法性(如时、分、秒的取值范围),同时以分为单位计算每位同学的科研时间; (2) 考勤信息浏览功能,显示所有研究生的考勤情况;例如: ---------------------------------------------------------------------------------------------------------------------- 学号 姓名 到达时间 离开时间 科研时间 排名 ---------------------------------------------------------------------------------------------------------------------- 201101 张三 08:00:00 17:12:00 492 3 201102 李四 09:10:20 17:30:20 500 2 201103 王五 08: 10:20 16:10:20 540 1 ---------------------------------------------------------------------------------------------------------------------- (3) 排序功能,按科研时间长短进行排序并显示 提示: (1) 使用数组、结构体 (2) 使用排序算法 ``` // 课程设计.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include "iostream" #include "string" #include "iomanip" #include "vector" #include<fstream> #include<algorithm> #include<iomanip> using namespace std; class student{ protected: string name;//姓名 string studentId;//学号 int hour;//签到小时 int minute;//签到分钟 int second;//签到秒数 int chour;//签退小时 int cminute;//签退分钟 int csecond;//签退秒数 int researchTime[100];//科研时间 int ranking;//排名 public: /*构造函数 初始化变量*/ student(){ name = ""; studentId = ""; hour = 0; minute = 0; second = 0; chour = 0; cminute = 0; csecond = 0; ranking = 0; researchTime[100] = 0; } bool set_name(string); bool set_studentId(string); bool set_hour(int); bool set_minute(int); bool set_second(int); bool set_chour(int); bool set_cminute(int); bool set_csecond(int); bool set_researchTime(int); bool set_ranking(int); string get_name(); string get_studentId(); int get_hour(); int get_minute(); int get_second(); int get_chour(); int get_cminute(); int get_csecond(); int get_researchTime(); int get_ranking(); }; bool student::set_studentId(string ID){ studentId = ID; return true; } bool student::set_name(string na){ name = na; return true; } bool student::set_hour(int ho){ hour = ho; return true; } bool student::set_minute(int mi){ minute = mi; return true; } bool student::set_second(int se){ second = se; return true; } bool student::set_chour(int cho){ chour = cho; return true; } bool student::set_cminute(int cmi){ cminute = cmi; return true; } bool student::set_csecond(int cse){ csecond = cse; return true; } bool student::set_researchTime(int res){ researchTime[10] = res; return true; } bool student::set_ranking(int ran){ ranking = ran; return true; } string student::get_studentId(){ return studentId; } string student::get_name(){ return name; } int student::get_hour(){ return hour; } int student::get_minute(){ return minute; } int student::get_second(){ return second; } int student::get_chour(){ return chour; } int student::get_cminute(){ return cminute; } int student::get_csecond(){ return csecond; } int student::get_researchTime(){ return researchTime[10]; } int student::get_ranking(){ return ranking; } void drow(){ cout << endl; cout << "********考勤统计********" << endl; cout << " " << "请输入相应字母进行操作!" << endl; cout << " " << "L:信息录入(Log in)" << endl; cout << " " << "O:输出(Output)" << endl; cout << " " << "E:退出(Exit)" << endl; cout << "************************" << endl; } student *Registration(){ student *temp; string info; int timeIn = NULL; temp = new student; cout << "你的学号" << endl; cin >> info; temp->set_studentId(info); cout << "你的姓名" << endl; cin >> info; temp->set_name(info); cout << "***到达时间(按提示依次录入时,分,秒)***" << endl; cout << "到达整点" << endl; cin >> timeIn; if (timeIn >= 0 && timeIn < 24){ temp->set_hour(timeIn); } else { cout << "输入有误,请重新输入" << endl; cin >> timeIn; temp->set_hour(timeIn); } cout << "到达分钟" << endl; cin >> timeIn; if (timeIn >= 0 && timeIn < 60){ temp->set_minute(timeIn); } else{ cout << "输入有误,请重新输入" << endl; cin >> timeIn; temp->set_minute(timeIn); } cout << "到达秒数" << endl; cin >> timeIn; if (timeIn >= 0 && timeIn < 60){ temp->set_second(timeIn); } else {cout << "输入有误,请重新输入" << endl; cin >> timeIn; temp->set_second(timeIn); } cout << "***离开时间(按提示依次录入时,分,秒)***" << endl; cout << "离开整点" << endl; cin >> timeIn; if (timeIn >= 0 && timeIn < 24){ temp->set_chour(timeIn); } else { cout << "输入有误,请重新输入" << endl; cin >> timeIn; temp->set_chour(timeIn); } cout << "离开分钟" << endl; cin >> timeIn; if (timeIn >= 0 && timeIn < 60){ temp->set_cminute(timeIn); } else{ cout << "输入有误,请重新输入" << endl; cin >> timeIn; temp->set_cminute(timeIn); } cout << "离开秒数" << endl; cin >> timeIn; if (timeIn >= 0 && timeIn < 60){ temp->set_csecond(timeIn); } else { cout << "输入有误,请重新输入" << endl; cin >> timeIn; temp->set_csecond(timeIn); } cout << endl << "信息录入成功=^_^=" << endl; return temp; } void ResearchTime(student *temp){ int reschT = ((temp->get_chour()) * 60 + temp->get_cminute()) - ((temp->get_hour()) * 60 + temp->get_minute()) ; temp->set_researchTime(reschT); int i = 0; i += 1; temp->set_ranking(i); } void save(student *temp){ ofstream os;//文件操作 os.open("outfile.txt",ios::app); os << endl; os << setw(2) << "学生学号:" << temp->get_studentId() << endl; os << setw(2) << "学生姓名:" << temp->get_name() << endl; os << setw(2) << "签到时间:" << setw(2) << setfill('0') << temp->get_hour(); os << ":" << setw(2) << setfill('0') << temp->get_minute() << ":"; os << setw(2) << setfill('0') << temp->get_second() << endl; os << setw(2) << "签退时间:" << setw(2) << setfill('0') << temp->get_chour(); os << ":" << setw(2) << setfill('0') << temp->get_cminute() << ":"; os << setw(2) << setfill('0') << temp->get_csecond() << endl; os << setw(2) << "科研时间:" << temp->get_researchTime() << endl; os << setw(2) << "时间排名:" << temp->get_ranking() << endl; temp++; os.close(); } void read(){ filebuf *pbuf; ifstream is; long size; char *buffer; if (!is){ cout << "读取不到" << endl; } //采用二进制读取整个文件 is.open("outfile.txt", ios::binary); // 获取filestr对应buffer对象的指针 pbuf = is.rdbuf(); // 调用buffer对象方法获取文件大小 size = pbuf->pubseekoff(0, ios::end, ios::in); pbuf->pubseekpos(0, ios::in); // 分配内存空间 buffer = new char[size]; // 获取文件内容 pbuf->sgetn(buffer, size); is.close(); // 输出到标准输出 cout.write(buffer, size); delete[]buffer; } int _tmain(int argc, _TCHAR* argv[]) { student s; student *temp=NULL; int i = 1; char input = 'e'; input = 'i'; while (input != 'e'){ drow(); cin >> input; input = tolower(input);//大写转义为小写 switch (input) { case 'l': cout << "信息录入:" << endl; temp = Registration(); ResearchTime(temp); save(temp); break; case 'o': read(); cout << endl << "信息读取成功=^_^= ,按提示信息进行其他操作" << endl; break; case'e': cout << "谢谢使用,再见!" << endl; std::system("pause"); std::exit(0); break; default: cout << "输入有误" << endl; break; } } std::system("pause"); return 0; } ```
在平面镜上光路路经角度的计算,怎么使用的C语言的程序的编写设计的程序代码来完成这个计算
Problem Description Dr. Evil has contracted your valuable services to build for him the world's most powerful "laser". Of course before you spend one billion dollars building the thing, you want to run some simulations first to make sure everything will work as designed. For this phase of the project, you will be simulating part of the aiming system which uses mirrors and other optics to change the direction of the laser beam. The simulation consists of a flat square table with mirrors, beam splitters, and beam detectors arranged on the tabletop, and with each object represented by a one dimensional line segment. The list below describes each of the object types in detail: mirror : A mirror object will reflect any laser beam striking its surface. The reflected beam leaves at the same angle of incidence as the incoming beam. Note that both sides of a mirror object are reflective. detector : A detector is an opaque object which absorbs any laser beam striking it. The simulation must also keep track of which detectors are struck by a laser for program output purposes. Note that a laser beam strike on either side of a detector counts as a "hit". splitter : When a laser beam strikes a splitter, it divides into two beams. One of the new beams will reflect from the splitter surface (as with a mirror), and the other beam will pass through the splitter without changing direction. A splitter will function the same way regardless which side of it is struck by a laser beam. See the figures below for examples of a laser beam's interaction with each of the possible object types: For each simulation, a single laser beam enters the tabletop area. The program must compute the path taken by the laser beam (including secondary beams due to splitters), and it must determine which detectors are struck by a laser beam. You can make the following assumptions in the program: 1. The tabletop surface is a 100 by 100 square, and unless otherwise specified all coordinates in the program's input are given as integers within the tabletop area (i.e. between 0 and 100 inclusive). 2. There will be no overlaps between the line 2. segment objects. 3. The laser which enters the tabletop area always starts from the edge of the table. 4. The simulation of each data set ends when all laser beams have either exited the table top area or have terminated at a detector. 5. For each data set there will be no more than 100 total reflections among all laser beams in that data set. 6. A laser beam will never intersect any object on a vertex and will never be collinear with an object's line segment. 7. Each data set will contain at least one detector object. Input Input to this problem will begin with a line containing a single integer N (1 ≤ N ≤ 100) indicating the number of data sets. Each data set consists of the following components: A single line with four numbers "x,y i,j" where x,y is a point along the table edge at which the laser beam enters, and i,j is a vector with integer components(-1024 ≤ i,j ≤ 1024) specifying the direction of the incoming laser beam, where i corresponds to the x-axis direction and j corresponds to the y-axis direction. A line with a single integer P (1 ≤ P ≤ 100) giving the total number of objects in this data set. A series of P lines, each representing one object, with the first line describing object 1, the second line describing object 2, and so on. Each line begins with a single letter specifying the object type where a "M" indicates a mirror object, "S" a splitter, and "D" a detector. This is followed by two coordinate pairs of the form "x,y", specifying the two end points of the object's line segment. Output For each data set in the input, output the heading "DATA SET #k" where k is 1 for the first data set, 2 for the second, etc. If in this data set none of the detector objects are struck by any laser beams, output the message "NO BEAMS DETECTED". Otherwise, output the object number, one per line, of each detector struck by a laser beam. The list of detectors should be sorted by their object numbers and output in ascending order. If a detector is struck by more than one laser beam, it should only be listed once in the output. Sample Input 1 50,100 0,-1 6 D 0,40 20,20 M 40,20 60,40 D 80,20 100,40 D 0,70 20,90 S 40,90 60,70 D 80,90 100,70 Sample Output DATA SET #1 1 6
求大神帮我看看 这c++程序问题出在哪里
// BaseShape.h文件 #include <iostream> using namespace std; class BaseShape { public: BaseShape() {}; virtual ~BaseShape() {}; virtual void DrawShape() = 0; }; //********************************* //ShapeFactory.h文件 #include <fstream> #include <string> #include " Echelon.h" #include "Line.h" #include "EquilateralTriangle.h" #include "RightTriangle.h" #include "Rectangle.h" #include "Square.h" #include "Diamond.h" #include "BaseShape.h" //定义工厂类 class ShapeFactory { public: ShapeFactory(); ~ShapeFactory(); //BaseShape* SelectShape(string); BaseShape* SelectShape(string shape) { if(shape=="Line" || shape=="线") return new Line(); if(shape=="RightTriangle" || shape=="直角三角形") return new RightTriangle(); if(shape=="EquilateralTriangle" || shape=="等边三角形") return new EquilateralTriangle(); if(shape=="Rectangle" || shape=="矩形") return new Rectangle(); if(shape=="Square" || shape=="正方形") return new Square(); if(shape=="Diamond" || shape=="菱形") return new Diamond(); if(shape==" Echelon " ||shape=="梯形") return new Echelon (); else cout<< "输入的图形名称错误!" <<endl; } }; // ShapeFactory.cpp文件 #include "ShapeFactory.h" ShapeFactory::ShapeFactory(void) { } ShapeFactory::~ShapeFactory(void) { } //******************************************** // Line.h文件 ///////////////////直线Line///////////////////// #include "BaseShape.h" class Line : public BaseShape { private: int n; static int L; public: Line() {}; virtual ~Line() {}; //构造函数成员初始化列表,构造函数之后,函数体之前。 Line ( int n) : n(n) { } //覆盖抽象类的纯虚函数 virtual void DrawShape(); }; // Line.cpp文件 #include "Line.h" //绘制直线 void Line ::DrawShape() { int n; static int L; cout<< "请选择直线长度: " <<endl; cin>> n; for(int i=0; i<n; i++) { cout<< "*" ; } L++; cout<<endl<< "^_^ 您已经绘制"<< L << "条直线^_^ "<<endl; } //******************************************** //Echelon.h文件 ///////////////////梯形Echelon///////////////////// #include "BaseShape.h" class Echelon : public BaseShape { private: int upside, downside; static int E; public: Echelon() {}; virtual ~Echelon() {}; Echelon ( int upside, int downside) : upside(upside), downside(downside) { } virtual void DrawShape(); }; //Echelon.cpp文件 //绘制梯形 void Echelon::DrawShape() { int upside, downside; static int E; cout<< "请选择输入要组成梯形的上底、下底:"; cin>> upside >> downside; for (int i=upside; i<downside; i++) { for(int j=downside-i; j>0; j--) { cout<<" "; } for(int k=1; k<=i+2; k++) { cout<< "* "; } cout<<endl; } E++; cout<<endl<< "^_^ 您已经绘制"<< E << "个梯形^_^ " <<endl; } //********************************************* // Diamond.h文件 ///////////////////菱形Diamond///////////////////// #include "BaseShape.h" class Diamond :public BaseShape { private: int n; static int D; public: Diamond(){}; virtual ~Diamond() {}; //构造函数成员初始化列表,构造函数之后,函数体之前。 Diamond ( int n) : n(n) { } //覆盖抽象类的纯虚函数 virtual void DrawShape(); }; // Diamond.cpp文件 #include "Diamond.h" //绘制菱形 void Diamond::DrawShape () { int n; static int D; cout<<"要得到的菱形的边长大小:"<<endl; cin>> n; ////////////上三角////////// for(int i=1;i<=n;++i) { for(int j=1;j<=n-i;++j) cout<<" "; for(j=1;j<=i;++j) cout<<"* "; cout<<endl; } //////////下三角/////////// for( i=n;i>=1;--i) { for(int j=1;j<=n-i;++j) cout<<" "; for(j=1;j<=i;++j) cout<<"* "; cout<<endl; } D++; cout<<endl<< "^_^ 您已经绘制"<< D << "个菱形^_^ "<<endl; } //********************************************* // EquilateralTriangle.h文件 ////////////////等边三角形EquilateralTriangle////////////////// #include "BaseShape.h" class EquilateralTriangle : public BaseShape { private: int n; static int ET; public: EquilateralTriangle() {}; virtual ~EquilateralTriangle() {}; //构造函数成员初始化列表,构造函数之后,函数体之前。 EquilateralTriangle ( int n) : n(n) { } //覆盖抽象类的纯虚函数 virtual void DrawShape(); }; // EquilateralTriangle.cpp文件. #include "EquilateralTriangle.h" //绘制等边三角形 void EquilateralTriangle::DrawShape() { int n; static int ET; cout<< "请选择输入要组成等边三角形的行数n(n>2):"; cin>>n; for(int i=1; i<n+1; i++) { //控制行数 //控制每行星号个数 for(int j=n-i; j>=0; j--) { cout<< " "; } for(int k=1; k<=2*i-1; k++) { cout<< "* "; } cout<<endl; } ET++; cout<<endl<< "^_^ 您已经绘制"<< ET << "个等边三角形^_^ "<<endl; } //********************************************* // Rectangle.h文件 ///////////////////矩形Rectangle///////////////////// #include "BaseShape.h" class Rectangle:public BaseShape { private: int width, height; static int R; public: Rectangle() {}; virtual ~Rectangle() {}; Rectangle( int width, int height) : width(width), height(height){ } virtual void DrawShape(); }; // Rectangle.cpp文件 #include "Rectangle.h" //绘制矩形 void Rectangle::DrawShape() { int width, height; static int R; cout<< "请选择输入矩形的长和宽: "; cin>> width >> height; cout<<endl; for (int i=1; i<=height; i++) { if (i==1 || i==height) {//输出长,即第一行和最后一行星号 for(int j=1; j<=width; j++) cout<< "* "; cout<<endl; } else { cout<< "*"; for(int j=2; j<=2*(width-2)+2; j++)//其中2*(side-2)+2为宽除星号外的空格数 cout<< " "; cout<< "*" <<endl; } } R++; cout<<endl<< "^_^ 您已经绘制"<< R << "个矩形^_^ "<<endl; } //********************************************* // RightTriangle.h文件 ///////////////////直角三角形RightTriangle ///////////////////// #include "BaseShape.h" class RightTriangle : public BaseShape { private: int n; static int RT; public: RightTriangle() {}; virtual ~RightTriangle() {}; //构造函数成员初始化列表,构造函数之后,函数体之前。 RightTriangle ( int n) : n(n) { } //覆盖抽象类的纯虚函数 virtual void DrawShape(); }; // RightTriangle.cpp文件 #include "RightTriangle.h" //绘制直角三角形 void RightTriangle::DrawShape() { int n; static int RT; cout<< "请选择输入要组成直角三角形的行数n(n>2):"; cin>>n; for(int i=0; i<n; i++) { //控制行数 for(int j=1; j<=i+1; j++)//控制每行星号个数 { cout<< "* "; } cout<<endl; } RT++; cout<<endl<< "^_^ 您已经绘制"<< RT << "个直角三角形^_^ "<<endl; } //********************************************* // Square.h文件 ///////////////////正方形Square///////////////////// #include "BaseShape.h" class Square : public BaseShape { private: int side; static int s; public: Square() {}; virtual ~Square() {}; Square ( int side) : side(side) { } virtual void DrawShape(); }; // Square.cpp文件 #include "Square.h" //绘制正方形 void Square::DrawShape() { static int s; int side; cout<< "请选择输入正方形的边长: "; cin>> side; cout<<endl; for (int i=1; i<=side; i++) { if (i==1 || i==side) {//输出长,即第一行和最后一行星号 for(int j=1; j<=side; j++) cout<< "* "; cout<<endl; } else { cout<< "*"; for(int j=2;j<=2*(side-2)+2;j++)//其中2*(side-2)+2为宽除星号外的空格数 cout<< " "; cout<< "*" <<endl; } } s++; cout<<endl<< "^_^ 您已经绘制"<< s << "个正方形^_^ "<<endl; } //********************************************* /* 设计一个使用空格和星号绘制图形的工厂,该工厂可以根据用户选择绘制不同的图形(如矩形?三角形?菱形?平行四边形?梯形等)? 具体要求: (1)至少能够绘制6种以上的图形? (2)可以绘制的图形名称保存在文本文件中? (3)根据用户选择设置图形参数绘制图形,并记录绘制了的图形的个数? (4)显示已经绘制的图形的总数? */ #include <fstream> #include <vector> #include <string> #include " Echelon.h" #include "Line.h" #include "EquilateralTriangle.h" #include "RightTriangle.h" #include "Rectangle.h" #include "Square.h" #include "Diamond.h" #include "BaseShape.h" #include "ShapeFactory.h" #include <iostream> using namespace std; int main() { /* 读infile类 的文件ShapeFactoryFile.txt中可绘制的图形并为每行加上"行号-",输出到运行屏幕上。 */ ifstream infile("ShapeFactoryFile.txt"); if(!infile) {//检验文件是否成功打开 cout<< "sorry! Unable to open ShapeFactoryFile. " <<endl; return -1; } string line; vector<string> text; while (getline(infile,line)) { text.push_back(line); } for(int j=0; j<text.size(); j++) cout<< j+1 << " - " << text[j] <<endl; cout<<endl << "*************以上是可以绘制的图形名***************" <<endl<<endl; //定义工厂对象、基类指针 ShapeFactory factory; BaseShape * pBaseShape; string shape; int t=0; while(true) { cout<<"请输入图形(英文或中文)名称(以#为结束程序): "; cin>>shape; if(shape=="#") break; BaseShape* pBaseShape=factory.SelectShape(shape);//选择具体类 pBaseShape->DrawShape();//调用具体类的画法 delete pBaseShape; t++; cout<< "您总共已经输出"<< t <<"个图形。" <<endl; } return 0; }
C++编程问题:不懂如何用rotate实现插入排序求指教。源代码如下
#ifndef _INSERTIONSORT_H #define _INSERTIONSORT_H #include<algorithm> using namespace std; template<typename Iterator> void insertionSort(const Iterator &a, const Iterator &b){ int i,j,n=distance(a,b); Iterator p,q,t; for(j=1,q=p=a,p++,t=p;j<n;j++,q=p,p++){//p璺熻釜a[j] i=j-1; while((i>=0)&&(*q>*p)) q--,i--; q++;//q璺熻釜a[i+1] t++;//t璺熻釜a[j+1] rotate(q,p,t); } } //template<typename Iterator> //void insertionSort(const Iterator &a, const Iterator &b){ // typedef typename iterator_traits<Iterator>::value_type T; // int i,j,n=distance(a,b); // T key; // Iterator p,q,t; // for(j=1,q=p=a,p++,t=p;j<n;j++,q=p,p++,t=p){//p璺熻釜a[j] // key=*p;//key鈫恆[j] // i=j-1; // while((i>=0)&&(*q>key)){ // *t=*q;//a[i+1]鈫恆[i] // i--,t--,q--; // } // *t=key;//a[i+1]鈫恔ey // } //} template<typename Iterator,typename Comparator> void insertionSort(const Iterator &a, const Iterator &b){ int i,j,n=distance(a,b); Iterator p,q,t; for(j=1,q=p=a,p++,t=p;j<n;j++,q=p,p++){//p璺熻釜a[j] i=j-1; while((i>=0)&&Comparator()(*q,*p)) q--,i--; q++;//q璺熻釜a[i+1] t++;//t璺熻釜a[j+1] rotate(q,p,t); } } #endif /* _INSERTIONSORT_H */ 测试代码: #include<iostream> #include<string> #include<vector> #include<list> #include<algorithm> #include<functional> using namespace std; #include "../Utility/partition.h" #include "../Utility/merge.h" #include "insertionsort.h" int main(int argc, char** argv){ // int a[]={1,2,5,8,9,0,3,4,6,7},i; int a[]={9,8,5,2,1,7,6,4,3,0},i; string b[]={"AoMen","BeiJing","ShangHai","ChongQing","TianJin","XiangGang"}; // double c[]={0.5,3.7,6.3,8.5,9.2,1.7,2.3,4.1,5.9,7.4}; double c[]={9.2,8.5,6.3,3.7,0.5,7.4,5.9,4.1,2.3,1.7}; vector<string> vb=vector<string>(b,b+6); list<double> lc=list<double>(c,c+10); // insertionSort<int*,less<int> >(a,a+10); merge<int*,greater<int> >(a,a+5,a+10); // inplace_merge(a,a+5,a+10,greater<int>()); copy(a,a+10, ostream_iterator<int>(cout, " ")); cout<<endl; merge(vb.begin(),vb.begin()+3,vb.end()); // inplace_merge(vb.begin(),vb.begin()+3,vb.end()); // insertionSort<vector<string>::iterator,less<string> >(vb.begin(),vb.end()); copy(vb.begin(),vb.end(), ostream_iterator<string>(cout, " ")); cout<<endl; list<double>::iterator m=lc.begin(); advance(m,5); merge<list<double>::iterator,greater<double> >(lc.begin(),m,lc.end()); // inplace_merge(lc.begin(),m,lc.end(),greater<double>()); // insertionSort<list<double>::iterator,less<double> >(lc.begin(),lc.end()); copy(lc.begin(),lc.end(), ostream_iterator<double>(cout, " ")); cout<<endl; return (EXIT_SUCCESS); } 参考于《算法设计、分析与实现C、C++和Java》
相见恨晚的超实用网站
搞学习 知乎:www.zhihu.com 简答题:http://www.jiandati.com/ 网易公开课:https://open.163.com/ted/ 网易云课堂:https://study.163.com/ 中国大学MOOC:www.icourse163.org 网易云课堂:study.163.com 哔哩哔哩弹幕网:www.bilibili.com 我要自学网:www.51zxw
花了20分钟,给女朋友们写了一个web版群聊程序
参考博客 [1]https://www.byteslounge.com/tutorials/java-ee-html5-websocket-example
爬虫福利二 之 妹子图网MM批量下载
爬虫福利一:27报网MM批量下载    点击 看了本文,相信大家对爬虫一定会产生强烈的兴趣,激励自己去学习爬虫,在这里提前祝:大家学有所成! 目标网站:妹子图网 环境:Python3.x 相关第三方模块:requests、beautifulsoup4 Re:各位在测试时只需要将代码里的变量 path 指定为你当前系统要保存的路径,使用 python xxx.py 或IDE运行即可。
字节跳动视频编解码面经
引言 本文主要是记录一下面试字节跳动的经历。 三四月份投了字节跳动的实习(图形图像岗位),然后hr打电话过来问了一下会不会opengl,c++,shador,当时只会一点c++,其他两个都不会,也就直接被拒了。 七月初内推了字节跳动的提前批,因为内推没有具体的岗位,hr又打电话问要不要考虑一下图形图像岗,我说实习投过这个岗位不合适,不会opengl和shador,然后hr就说秋招更看重基础。我当时
Java学习的正确打开方式
在博主认为,对于入门级学习java的最佳学习方法莫过于视频+博客+书籍+总结,前三者博主将淋漓尽致地挥毫于这篇博客文章中,至于总结在于个人,实际上越到后面你会发现学习的最好方式就是阅读参考官方文档其次就是国内的书籍,博客次之,这又是一个层次了,这里暂时不提后面再谈。博主将为各位入门java保驾护航,各位只管冲鸭!!!上天是公平的,只要不辜负时间,时间自然不会辜负你。 何谓学习?博主所理解的学习,它
程序员必须掌握的核心算法有哪些?
由于我之前一直强调数据结构以及算法学习的重要性,所以就有一些读者经常问我,数据结构与算法应该要学习到哪个程度呢?,说实话,这个问题我不知道要怎么回答你,主要取决于你想学习到哪些程度,不过针对这个问题,我稍微总结一下我学过的算法知识点,以及我觉得值得学习的算法。这些算法与数据结构的学习大多数是零散的,并没有一本把他们全部覆盖的书籍。下面是我觉得值得学习的一些算法以及数据结构,当然,我也会整理一些看过
大学四年自学走来,这些私藏的实用工具/学习网站我贡献出来了
大学四年,看课本是不可能一直看课本的了,对于学习,特别是自学,善于搜索网上的一些资源来辅助,还是非常有必要的,下面我就把这几年私藏的各种资源,网站贡献出来给你们。主要有:电子书搜索、实用工具、在线视频学习网站、非视频学习网站、软件下载、面试/求职必备网站。 注意:文中提到的所有资源,文末我都给你整理好了,你们只管拿去,如果觉得不错,转发、分享就是最大的支持了。 一、电子书搜索 对于大部分程序员...
linux系列之常用运维命令整理笔录
本博客记录工作中需要的linux运维命令,大学时候开始接触linux,会一些基本操作,可是都没有整理起来,加上是做开发,不做运维,有些命令忘记了,所以现在整理成博客,当然vi,文件操作等就不介绍了,慢慢积累一些其它拓展的命令,博客不定时更新 顺便拉下票,我在参加csdn博客之星竞选,欢迎投票支持,每个QQ或者微信每天都可以投5票,扫二维码即可,http://m234140.nofollow.ax.
比特币原理详解
一、什么是比特币 比特币是一种电子货币,是一种基于密码学的货币,在2008年11月1日由中本聪发表比特币白皮书,文中提出了一种去中心化的电子记账系统,我们平时的电子现金是银行来记账,因为银行的背后是国家信用。去中心化电子记账系统是参与者共同记账。比特币可以防止主权危机、信用风险。其好处不多做赘述,这一层面介绍的文章很多,本文主要从更深层的技术原理角度进行介绍。 二、问题引入 假设现有4个人...
Python 基础(一):入门必备知识
目录1 标识符2 关键字3 引号4 编码5 输入输出6 缩进7 多行8 注释9 数据类型10 运算符10.1 常用运算符10.2 运算符优先级 1 标识符 标识符是编程时使用的名字,用于给变量、函数、语句块等命名,Python 中标识符由字母、数字、下划线组成,不能以数字开头,区分大小写。 以下划线开头的标识符有特殊含义,单下划线开头的标识符,如:_xxx ,表示不能直接访问的类属性,需通过类提供
这30个CSS选择器,你必须熟记(上)
关注前端达人,与你共同进步CSS的魅力就是让我们前端工程师像设计师一样进行网页的设计,我们能轻而易举的改变颜色、布局、制作出漂亮的影音效果等等,我们只需要改几行代码,不需...
国产开源API网关项目进入Apache孵化器:APISIX
点击蓝色“程序猿DD”关注我回复“资源”获取独家整理的学习资料!近日,又有一个开源项目加入了这个Java开源界大名鼎鼎的Apache基金会,开始进行孵化器。项目名称:AP...
程序员接私活怎样防止做完了不给钱?
首先跟大家说明一点,我们做 IT 类的外包开发,是非标品开发,所以很有可能在开发过程中会有这样那样的需求修改,而这种需求修改很容易造成扯皮,进而影响到费用支付,甚至出现做完了项目收不到钱的情况。 那么,怎么保证自己的薪酬安全呢? 我们在开工前,一定要做好一些证据方面的准备(也就是“讨薪”的理论依据),这其中最重要的就是需求文档和验收标准。一定要让需求方提供这两个文档资料作为开发的基础。之后开发
网页实现一个简单的音乐播放器(大佬别看。(⊙﹏⊙))
今天闲着无事,就想写点东西。然后听了下歌,就打算写个播放器。 于是乎用h5 audio的加上js简单的播放器完工了。 欢迎 改进 留言。 演示地点跳到演示地点 html代码如下`&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;music&lt;/title&gt; &lt;meta charset="utf-8"&gt
Python十大装B语法
Python 是一种代表简单思想的语言,其语法相对简单,很容易上手。不过,如果就此小视 Python 语法的精妙和深邃,那就大错特错了。本文精心筛选了最能展现 Python 语法之精妙的十个知识点,并附上详细的实例代码。如能在实战中融会贯通、灵活使用,必将使代码更为精炼、高效,同时也会极大提升代码B格,使之看上去更老练,读起来更优雅。 1. for - else 什么?不是 if 和 else 才
数据库优化 - SQL优化
前面一篇文章从实例的角度进行数据库优化,通过配置一些参数让数据库性能达到最优。但是一些“不好”的SQL也会导致数据库查询变慢,影响业务流程。本文从SQL角度进行数据库优化,提升SQL运行效率。 判断问题SQL 判断SQL是否有问题时可以通过两个表象进行判断: 系统级别表象 CPU消耗严重 IO等待严重 页面响应时间过长
2019年11月中国大陆编程语言排行榜
2019年11月2日,我统计了某招聘网站,获得有效程序员招聘数据9万条。针对招聘信息,提取编程语言关键字,并统计如下: 编程语言比例 rank pl_ percentage 1 java 33.62% 2 c/c++ 16.42% 3 c_sharp 12.82% 4 javascript 12.31% 5 python 7.93% 6 go 7.25% 7
通俗易懂地给女朋友讲:线程池的内部原理
餐厅的约会 餐盘在灯光的照耀下格外晶莹洁白,女朋友拿起红酒杯轻轻地抿了一小口,对我说:“经常听你说线程池,到底线程池到底是个什么原理?”我楞了一下,心里想女朋友今天是怎么了,怎么突然问出这么专业的问题,但做为一个专业人士在女朋友面前也不能露怯啊,想了一下便说:“我先给你讲讲我前同事老王的故事吧!” 大龄程序员老王 老王是一个已经北漂十多年的程序员,岁数大了,加班加不动了,升迁也无望,于是拿着手里
经典算法(5)杨辉三角
杨辉三角 是经典算法,这篇博客对它的算法思想进行了讲解,并有完整的代码实现。
编写Spring MVC控制器的14个技巧
本期目录 1.使用@Controller构造型 2.实现控制器接口 3.扩展AbstractController类 4.为处理程序方法指定URL映射 5.为处理程序方法指定HTTP请求方法 6.将请求参数映射到处理程序方法 7.返回模型和视图 8.将对象放入模型 9.处理程序方法中的重定向 10.处理表格提交和表格验证 11.处理文件上传 12.在控制器中自动装配业务类 ...
腾讯算法面试题:64匹马8个跑道需要多少轮才能选出最快的四匹?
昨天,有网友私信我,说去阿里面试,彻底的被打击到了。问了为什么网上大量使用ThreadLocal的源码都会加上private static?他被难住了,因为他从来都没有考虑过这个问题。无独有偶,今天笔者又发现有网友吐槽了一道腾讯的面试题,我们一起来看看。 腾讯算法面试题:64匹马8个跑道需要多少轮才能选出最快的四匹? 在互联网职场论坛,一名程序员发帖求助到。二面腾讯,其中一个算法题:64匹
面试官:你连RESTful都不知道我怎么敢要你?
面试官:了解RESTful吗? 我:听说过。 面试官:那什么是RESTful? 我:就是用起来很规范,挺好的 面试官:是RESTful挺好的,还是自我感觉挺好的 我:都挺好的。 面试官:… 把门关上。 我:… 要干嘛?先关上再说。 面试官:我说出去把门关上。 我:what ?,夺门而去 文章目录01 前言02 RESTful的来源03 RESTful6大原则1. C-S架构2. 无状态3.统一的接
求小姐姐抠图竟遭白眼?痛定思痛,我决定用 Python 自力更生!
点击蓝色“Python空间”关注我丫加个“星标”,每天一起快乐的学习大家好,我是 Rocky0429,一个刚恰完午饭,正在用刷网页浪费生命的蒟蒻...一堆堆无聊八卦信息的网页内容慢慢使我的双眼模糊,一个哈欠打出了三斤老泪,就在此时我看到了一张图片:是谁!是谁把我女朋友的照片放出来的!awsl!太好看了叭...等等,那个背景上的一堆鬼画符是什么鬼?!真是看不下去!叔叔婶婶能忍,隔壁老王的三姨妈的四表...
为啥国人偏爱Mybatis,而老外喜欢Hibernate/JPA呢?
关于SQL和ORM的争论,永远都不会终止,我也一直在思考这个问题。昨天又跟群里的小伙伴进行了一番讨论,感触还是有一些,于是就有了今天这篇文。 声明:本文不会下关于Mybatis和JPA两个持久层框架哪个更好这样的结论。只是摆事实,讲道理,所以,请各位看官勿喷。 一、事件起因 关于Mybatis和JPA孰优孰劣的问题,争论已经很多年了。一直也没有结论,毕竟每个人的喜好和习惯是大不相同的。我也看
SQL-小白最佳入门sql查询一
不要偷偷的查询我的个人资料,即使你再喜欢我,也不要这样,真的不好;
项目中的if else太多了,该怎么重构?
介绍 最近跟着公司的大佬开发了一款IM系统,类似QQ和微信哈,就是聊天软件。我们有一部分业务逻辑是这样的 if (msgType = "文本") { // dosomething } else if(msgType = "图片") { // doshomething } else if(msgType = "视频") { // doshomething } else { // doshom...
致 Python 初学者
欢迎来到“Python进阶”专栏!来到这里的每一位同学,应该大致上学习了很多 Python 的基础知识,正在努力成长的过程中。在此期间,一定遇到了很多的困惑,对未来的学习方向感到迷茫。我非常理解你们所面临的处境。我从2007年开始接触 python 这门编程语言,从2009年开始单一使用 python 应对所有的开发工作,直至今天。回顾自己的学习过程,也曾经遇到过无数的困难,也曾经迷茫过、困惑过。开办这个专栏,正是为了帮助像我当年一样困惑的 Python 初学者走出困境、快速成长。希望我的经验能真正帮到你
“狗屁不通文章生成器”登顶GitHub热榜,分分钟写出万字形式主义大作
一、垃圾文字生成器介绍 最近在浏览GitHub的时候,发现了这样一个骨骼清奇的雷人项目,而且热度还特别高。 项目中文名:狗屁不通文章生成器 项目英文名:BullshitGenerator 根据作者的介绍,他是偶尔需要一些中文文字用于GUI开发时测试文本渲染,因此开发了这个废话生成器。但由于生成的废话实在是太过富于哲理,所以最近已经被小伙伴们给玩坏了。 他的文风可能是这样的: 你发现,...
程序员:我终于知道post和get的区别
是一个老生常谈的话题,然而随着不断的学习,对于以前的认识有很多误区,所以还是需要不断地总结的,学而时习之,不亦说乎
《程序人生》系列-这个程序员只用了20行代码就拿了冠军
你知道的越多,你不知道的越多 点赞再看,养成习惯GitHub上已经开源https://github.com/JavaFamily,有一线大厂面试点脑图,欢迎Star和完善 前言 这一期不算《吊打面试官》系列的,所有没前言我直接开始。 絮叨 本来应该是没有这期的,看过我上期的小伙伴应该是知道的嘛,双十一比较忙嘛,要值班又要去帮忙拍摄年会的视频素材,还得搞个程序员一天的Vlog,还要写BU...
相关热词 c# plc s1200 c#里氏转换原则 c# 主界面 c# do loop c#存为组套 模板 c# 停掉协程 c# rgb 读取图片 c# 图片颜色调整 最快 c#多张图片上传 c#密封类与密封方法
立即提问