为什么我的ng-change在失去焦点后才执行?

我在select里写的ng-change调用了一个事件,但是在我点击了option的选项后
事件并没有马上执行,而是在我点击了外部,select失去焦点后才执行
这样实在是不美观,求个大神帮忙看下,谢谢!

<li><select style="height:28px;width:45px;margin-left: 5px;margin-right: 5px" ng-model="pagesize"
                        ng-model-options="{updateOn: 'blur'}"
                        ng-change="updatesize()">
                    <option value="1">1</option>
                    <option value="2">2</option>
                    <option value="3">3</option>
                </select>
                </li>

1个回答

ng-model-options="{updateOn: 'blur'}"这个属性设置了失去焦点改变值;

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
angular的ng-click不触发
``` <label class="item item-input item-input-psw"> <i class="icon-s icon-s-locked"></i> <div class="item-con" > <input type="{{pwshow?'password':'text'}}" ng-model="user.password" placeholder="输入密码" ng-change="iconShow()"> <div ng-class="{true: 'icon-s-clear-show', false: 'icon-s-clear-hide'}[isIconActive]" ng-click="iconClear()"></div> <a href="javascript:;" class="eye-click" item-end ng-Class="pwshow?'eyeshow':'eyehide'" ng-click="pwshow = !pwshow" > <div class="icon-s-eye"></div> </a> </div> </label> ``` 其中的两个ng-click事件不触发,如果绑定在外层的div上可以触发,可见不是函数等其他问题。 希望大神解决
angularJS ng-model无法获取WdatePicker清空之后的值
如题:angularJS ng-model无法获取WdatePicker清空之后的值 ``` <input id="startDate" type="text" ng-model="startDate" readonly="readonly" onclick="WdatePicker({dateFmt: 'yyyy-MM-dd HH:mm:ss',onpicked: function(){$(this).trigger('change')}})" class="form-control empty" /> console.log($("#startDate").val());//日历控件清空后显示"" console.log($scope.startDate);//日历控件清空后值未变化 ```
为什么我设置了ngf-multiple为true,虽然能选择多张图片了,但绑定的数据还是只有一张?
``` <input id="file-Portrait" name="file" type="file" class="form-control file-show" ng-disabled="!p_checkUserPwd" ngf-select ngf-keep="true" ngf-multiple="true" ng-model="file" required multiple data-allowed-file-extensions="['png','gif','jpg','jpeg']" ngf-max-size="5MB" ngf-accept="'image/*'" ngf-change="f_onFileSelect($file)" /> ``` 这样虽然能选择多张图片了,但controller绑定的数据还是只有一张图片的信息,这是为什么呢?
关于angularjs的失去焦点问题
在一个input上绑定失去焦点事件和change事件。在change时发ajax请求的同时会触发blur。怎么解决?
Exact Change 怎么做的呢
Problem Description * Seller: That will be fourteen dollars. * Buyer: Here's a twenty. * Seller: Sorry, I don't have any change. * Buyer: OK, here's a ten and a five. Keep the change. When travelling to remote locations, it is often helpful to bring cash, in case you want to buy something from someone who does not accept credit or debit cards. It is also helpful to bring a variety of denominations in case the seller does not have change. Even so, you may not have the exact amount, and will have to pay a little bit more than full price. The same problem can arise even in urban locations, for example with vending machines that do not return change. Of course, you would like to minimize the amount you pay (though you must pay at least as much as the value of the item). Moreover, while paying the minimum amount, you would like to minimize the number of coins or bills that you pay out. Input The first line of each test chunk contains an integer specifying the number of test cases in this chunk to follow. Each test case begins with a line containing an integer, the price in cents of the item you would like to buy. The price will not exceed 10 000 cents (i.e., 100).Thefollowinglinecontainsasingleintegern,thenumberofbillsandcoinsthatyouhave.Thenumbernisatmost100.Thefollowingnlineseachcontainoneinteger,thevalueincentsofeachbillorcointhatyouhave.Notethatthedenominationscanbeanynumberofcents;theyarenotlimitedtothevaluesofcoinsandbillsthatweusuallyuseinCanada.However,nobillorcoinwillhaveavaluegreaterthan10000cents(100). The total value of your bills and coins will always be equal to or greater than the price of the item. Please process to the end of the data file. Output For each test case, output a single line containing two integers: the total amount paid (in cents), and the total number of coins and bills used. Sample Input 1 1400 3 500 1000 2000 1 1400 3 500 1000 2000 Sample Output 1500 2 1500 2
elementUi的selection-all事件触发不了
![图片说明](https://img-ask.csdn.net/upload/202001/09/1578554773_864224.png) 点击全选按钮触发不了elementUi的selection-all事件 ``` <el-table border :data="this.autisticData" ref="multipleTable" style="width: 100%" @select="handleSelectionAutisticChange" @select-all="handleSelectionAutisticChangeAll" @change="aaa" > --------------------------------------- handleSelectionAutisticChangeAll(selection) { alert(888); // for (var i = 0; i < selection.length; i++) { // selection[i].disabled = false; // selection[i].severity = 1; // } }, aaa() { alert(666); }, ```
Change the ball
Problem Description Garfield has three piles of balls, each pile has unique color of following: yellow, blue, and red. Now we also know Garfield has Y yellow balls, B blue balls, and R red balls. But Garfield just wants to change all the balls to one color. When he puts two balls of different color togather, the balls then change their colors automatically into the rest color. For instance, when Garfield puts a red one and a yellow one togather, the two balls immediately owns blue color, the same to other situations. But the rule doesn’t work when the two balls have the same color. Garfield is not able to estimate the minimal steps to achieve the aim. Can you tell him? Input For each line, there are three intergers Y, B, R(1<=Y,B,R<=1000),indicate the number refered above. Output For each case, tell Garfield the minimal steps to complete the assignment. If not, output the symbol “):”. Sample Input 1 2 3 1 2 2 Sample Output ): 2
为什么我看了这个关于高校人员信息管理系统设计的代码运行时总是会说找不到“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; }
VUE V-TABLE 中始终会出现纵向滚动条
VUE V-TABLE 中始终会出现滚动条 (被隐藏的区域高度为 176px, 怀疑是否为分页偏移或者footer) 但是文档上面没有看到描述如何去除 ![图片说明](https://img-ask.csdn.net/upload/201912/31/1577765122_971852.png) 如图table,代码为: ``` <v-table is-horizontal-resize style="width:100%; height:420px;" even-bg-color="#f2f2f2" row-hover-color="#eee" row-click-color="#edf7ff" :columns="Ordercolumns" :table-data="Ordertablerows" :select-all="selectALL" :select-change="selectChange"></v-table> ``` ![图片说明](https://img-ask.csdn.net/upload/201912/31/1577765612_4254.png)
Exact Change 的思路用程序实现
Problem Description * Seller: That will be fourteen dollars. * Buyer: Here's a twenty. * Seller: Sorry, I don't have any change. * Buyer: OK, here's a ten and a five. Keep the change. When travelling to remote locations, it is often helpful to bring cash, in case you want to buy something from someone who does not accept credit or debit cards. It is also helpful to bring a variety of denominations in case the seller does not have change. Even so, you may not have the exact amount, and will have to pay a little bit more than full price. The same problem can arise even in urban locations, for example with vending machines that do not return change. Of course, you would like to minimize the amount you pay (though you must pay at least as much as the value of the item). Moreover, while paying the minimum amount, you would like to minimize the number of coins or bills that you pay out. Input The first line of each test chunk contains an integer specifying the number of test cases in this chunk to follow. Each test case begins with a line containing an integer, the price in cents of the item you would like to buy. The price will not exceed 10 000 cents (i.e., 100).Thefollowinglinecontainsasingleintegern,thenumberofbillsandcoinsthatyouhave.Thenumbernisatmost100.Thefollowingnlineseachcontainoneinteger,thevalueincentsofeachbillorcointhatyouhave.Notethatthedenominationscanbeanynumberofcents;theyarenotlimitedtothevaluesofcoinsandbillsthatweusuallyuseinCanada.However,nobillorcoinwillhaveavaluegreaterthan10000cents(100). The total value of your bills and coins will always be equal to or greater than the price of the item. Please process to the end of the data file. Output For each test case, output a single line containing two integers: the total amount paid (in cents), and the total number of coins and bills used. Sample Input 1 1400 3 500 1000 2000 1 1400 3 500 1000 2000 Sample Output 1500 2 1500 2
各位大佬,能不能帮我看看为什么pat1018石头剪刀布部分测试点过不了
![图片说明](https://img-ask.csdn.net/upload/202001/18/1579338138_725292.jpg) ![图片说明](https://img-ask.csdn.net/upload/202001/18/1579337962_98969.jpg)![图片说明](https://img-ask.csdn.net/upload/202001/18/1579337973_680047.jpg) ```#include<stdio.h> int change(char c) { if(c == 'B') return 0; else if(c == 'C') return 1; else if(c == 'J') return 2; } int main() { char c1, c2; int k1, k2; int ahand[3] = {0}; int bhand[3] = {0}; int ka[3] = {0}; int kb[3] = {0}; char mp[3] = {'B','C','J'}; int m1 = 0, m2 = 0; int n; scanf("%d", &n); for(int i = 0; i < n; i++) { getchar(); scanf("%c %c", &c1, &c2); k1 = change(c1); k2 = change(c2); if((k1+1)%3 == k2) { ahand[0]++; bhand[2]++; ka[k1]++; } else if((k2+1)%3 == k1) { ahand[2]++; bhand[0]++; ka[k2]++; } else { ahand[1]++; bhand[1]++; } } printf("%d %d %d\n", ahand[0], ahand[1], ahand[2]); printf("%d %d %d\n", bhand[0], bhand[1], bhand[2]); for(int i = 0; i < 3; i++) { if(ka[m1] < ka[i]) { m1 = i; } if(kb[m2] < kb[i]) { m2 = i; } } printf("%c %c\n", mp[m1], mp[m2]); return 0; } ```
程序的设计问题——Exact Change
Problem Description * Seller: That will be fourteen dollars. * Buyer: Here's a twenty. * Seller: Sorry, I don't have any change. * Buyer: OK, here's a ten and a five. Keep the change. When travelling to remote locations, it is often helpful to bring cash, in case you want to buy something from someone who does not accept credit or debit cards. It is also helpful to bring a variety of denominations in case the seller does not have change. Even so, you may not have the exact amount, and will have to pay a little bit more than full price. The same problem can arise even in urban locations, for example with vending machines that do not return change. Of course, you would like to minimize the amount you pay (though you must pay at least as much as the value of the item). Moreover, while paying the minimum amount, you would like to minimize the number of coins or bills that you pay out. Input The first line of each test chunk contains an integer specifying the number of test cases in this chunk to follow. Each test case begins with a line containing an integer, the price in cents of the item you would like to buy. The price will not exceed 10 000 cents (i.e., 100).Thefollowinglinecontainsasingleintegern,thenumberofbillsandcoinsthatyouhave.Thenumbernisatmost100.Thefollowingnlineseachcontainoneinteger,thevalueincentsofeachbillorcointhatyouhave.Notethatthedenominationscanbeanynumberofcents;theyarenotlimitedtothevaluesofcoinsandbillsthatweusuallyuseinCanada.However,nobillorcoinwillhaveavaluegreaterthan10000cents(100). The total value of your bills and coins will always be equal to or greater than the price of the item. Please process to the end of the data file. Output For each test case, output a single line containing two integers: the total amount paid (in cents), and the total number of coins and bills used. Sample Input 1 1400 3 500 1000 2000 1 1400 3 500 1000 2000 Sample Output 1500 2 1500 2
安卓调用百度地图sdk,可是返回坐标值一直是4.9E-324
我发现手机端使用正常,就是在使用夜神模拟器的时候出现的这样的问题。 打开夜神模拟器设置,发现我的软件有这个位置权限(手机端申请了动态权限) 但就是返回4.9E-324,location.getLocType()的返回值是167.我看文档说是没有获取到位置权限。 我现在就有一点迷惑了,动态的也申请了,也在AndroidManifest里面写了权限。 真心不知道这个bug咋解决。 以下是我mainactivity里面所有的代码: ``` package com.example.ppgo; import android.Manifest; import android.content.pm.PackageManager; import android.os.Bundle; import android.util.Log; import android.widget.TextView; import android.widget.Toast; import com.baidu.location.BDLocation; import com.baidu.location.BDLocationListener; import com.baidu.location.LocationClient; import com.baidu.location.LocationClientOption; import java.util.ArrayList; import java.util.List; import androidx.annotation.NonNull; import androidx.appcompat.app.AppCompatActivity; import androidx.core.app.ActivityCompat; import androidx.core.content.ContextCompat; public class MainActivity extends AppCompatActivity { public LocationClient mLocationClient; private TextView positionText; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mLocationClient=new LocationClient(getApplicationContext()); mLocationClient.registerLocationListener(new MyLocationListener()); setContentView(R.layout.activity_main); positionText=(TextView)findViewById(R.id.position_text_view); List<String> permissionList=new ArrayList<>(); if(ContextCompat.checkSelfPermission(MainActivity.this, Manifest. permission.ACCESS_FINE_LOCATION)!=PackageManager.PERMISSION_GRANTED){ permissionList.add(Manifest.permission.ACCESS_FINE_LOCATION); } if(ContextCompat.checkSelfPermission(MainActivity.this, Manifest. permission.READ_PHONE_STATE)!=PackageManager.PERMISSION_GRANTED){ permissionList.add(Manifest.permission.READ_PHONE_STATE); } if(ContextCompat.checkSelfPermission(MainActivity.this, Manifest. permission.WRITE_EXTERNAL_STORAGE)!=PackageManager.PERMISSION_GRANTED){ permissionList.add(Manifest.permission.WRITE_EXTERNAL_STORAGE); } if(!permissionList.isEmpty()){ String[]permissions=permissionList.toArray(new String[permissionList.size()]); ActivityCompat.requestPermissions(MainActivity.this,permissions,1); }else { requestLocation(); } } private void requestLocation(){ initLocation(); mLocationClient.start(); } private void initLocation(){ LocationClientOption option =new LocationClientOption(); option.setScanSpan(5000); mLocationClient.setLocOption(option); } @Override protected void onDestroy() { super.onDestroy(); mLocationClient.stop(); } @Override public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { super.onRequestPermissionsResult(requestCode, permissions, grantResults); Log.e("Tag","执行了onRequestPermissionsResult函数"); switch (requestCode){ case 1: if (grantResults.length>0){ for(int result:grantResults){ if(result!=PackageManager.PERMISSION_GRANTED){ Toast.makeText(this,"必须同意所有权限才能使用本程序", Toast.LENGTH_SHORT).show(); finish(); return; } } requestLocation(); }else { Toast.makeText(this,"发生未知错误",Toast.LENGTH_SHORT).show(); finish(); } break; default: } } public class MyLocationListener implements BDLocationListener { @Override public void onReceiveLocation(BDLocation location){ StringBuilder currentPosition=new StringBuilder(); currentPosition.append("纬度:").append(location.getLatitude()).append("\n"); currentPosition.append("经线:").append(location.getLongitude()).append("\n"); currentPosition.append("国家:").append(location.getCountry()).append("\n"); currentPosition.append("省:").append(location.getProvince()).append("\n"); currentPosition.append("市:").append(location.getCity()).append("\n"); currentPosition.append("区:").append(location.getDistrict()).append("\n"); currentPosition.append("街道:").append(location.getStreet()).append("\n"); currentPosition.append("定位方式:"); if (location.getLocType() == BDLocation.TypeGpsLocation) { currentPosition.append("GPS"); } else if (location.getLocType() == BDLocation.TypeNetWorkLocation) { currentPosition.append("网络"); currentPosition.append(" 错误代码:"+location.getLocType()); } else if (location.getLocType() == BDLocation.TypeOffLineLocation){ currentPosition.append("离线定位成功,离线定位结果也是有效的"); } else if (location.getLocType() == BDLocation.TypeServerError){ currentPosition.append("服务端网络定位失败"); currentPosition.append(" 错误代码:"+location.getLocType()); } else if (location.getLocType() == BDLocation.TypeNetWorkException){ currentPosition.append("网络不同导致定位失败,请检查网络是否通畅"); } else if (location.getLocType() == BDLocation.TypeCriteriaException){ currentPosition.append("无法获取有效定位依据导致定位失败"); currentPosition.append(" 错误代码:"+location.getLocType()); } else { currentPosition.append(location.getLocType()); //这里打印出来location.getLocType()是162 currentPosition.append("老子也不知道是啥原因!!!"); } positionText.setText(currentPosition); } } } ``` 以下是我AndroidManifest里面的代码: ``` <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.ppgo"> <!-- 这个权限用于进行网络定位 --> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <!-- 这个权限用于访问GPS定位 --> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <!-- 用于访问wifi网络信息,wifi信息会用于进行网络定位 --> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <!-- 获取网络状态,根据网络状态切换进行数据请求网络转换 --> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <!-- 写外置存储。如果开发者使用了离线地图,并且数据写在外置存储区域,则需要申请该权限 --> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <!-- 读取外置存储。如果开发者使用了so动态加载功能并且把so文件放在了外置存储区域,则需要申请该权限,否则不需要 --> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <!-- 访问网络,进行地图相关业务数据请求,包括地图数据,路线规划,POI检索等 --> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" /> <uses-permission android:name="android.permission.READ_PHONE_STATE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" /> <uses-permission android:name="android.permission.WAKE_LOCK" /> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme"> <meta-data android:name="com.baidu.lbsapi.API_KEY" android:value="mvxMsdG1homIlK4UjAWYP2itjxo09Dyy" /> <activity android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <service android:name="com.baidu.location.f" android:enabled="true" android:process=":remote" /> </application> </manifest> ```
C语言如何编写Exact Change
Problem Description * Seller: That will be fourteen dollars. * Buyer: Here's a twenty. * Seller: Sorry, I don't have any change. * Buyer: OK, here's a ten and a five. Keep the change. When travelling to remote locations, it is often helpful to bring cash, in case you want to buy something from someone who does not accept credit or debit cards. It is also helpful to bring a variety of denominations in case the seller does not have change. Even so, you may not have the exact amount, and will have to pay a little bit more than full price. The same problem can arise even in urban locations, for example with vending machines that do not return change. Of course, you would like to minimize the amount you pay (though you must pay at least as much as the value of the item). Moreover, while paying the minimum amount, you would like to minimize the number of coins or bills that you pay out. Input The first line of each test chunk contains an integer specifying the number of test cases in this chunk to follow. Each test case begins with a line containing an integer, the price in cents of the item you would like to buy. The price will not exceed 10 000 cents (i.e., 100).Thefollowinglinecontainsasingleintegern,thenumberofbillsandcoinsthatyouhave.Thenumbernisatmost100.Thefollowingnlineseachcontainoneinteger,thevalueincentsofeachbillorcointhatyouhave.Notethatthedenominationscanbeanynumberofcents;theyarenotlimitedtothevaluesofcoinsandbillsthatweusuallyuseinCanada.However,nobillorcoinwillhaveavaluegreaterthan10000cents(100). The total value of your bills and coins will always be equal to or greater than the price of the item. Please process to the end of the data file. Output For each test case, output a single line containing two integers: the total amount paid (in cents), and the total number of coins and bills used. Sample Input 1 1400 3 500 1000 2000 1 1400 3 500 1000 2000 Sample Output 1500 2 1500 2
tpp.c:84:__pthread_tpp_change_priority: Assertion `new_prio == -1 || (new_prio >= fifo_min_prio && new_prio <= fifo_max_prio)' failed.报错,请问这是什么错误?
tpp.c:84: __pthread_tpp_change_priority: Assertion `new_prio == -1 || (new_prio >= fifo_min_prio && new_prio <= fifo_max_prio)' failed. 请问这是什么错误,有哪位大神知道的帮帮我,谢谢
【求助笔试题]】 找出VB.NET写的21点扑克牌程序中的问题
遇到一个面试题,题目要求是这样的 写了一个21点扑克牌的程序,用VB.NET写的,需要你找出其中的bugs,尽可能多 的找出,并写明错误原因 由于小弟写C#的,对VB.NET实在不熟悉,还希望有经验前辈帮忙看看 小弟不胜感觉 代码一共有6个类 分别是 Blackjack Card Deck Game Hand Player ProbabilityCalculator 代码文件如下 ``` ''' <summary> ''' Emulates a black jack game between two different AI players. 模拟两个不同的AI玩家之间的黑杰克游戏。 ''' </summary> Public Class Blackjack Public Shared ReadOnly AllCards As New List(Of Card) ''' <summary> ''' Static constructor. ''' Generates a list containing one of every possible card.生成一个包含所有可能卡片的列表 ''' This simplified game assumes a single deck of 52 cards, one of every unique suit and rank combination. ''' 这个简化的游戏假设有一副52张的牌,每副牌都有自己独特的花色和等级组合。 ''' </summary> Shared Sub New() For Each s As Card.Suit In [Enum].GetValues(GetType(Card.Suit)) For Each r As Card.Rank In [Enum].GetValues(GetType(Card.Rank)) AllCards.Add(New Card(r, s)) Next Next End Sub ''' <summary> ''' Main method. Constructs the object, plays the game, prints the output. ''' Don't change this method! ''' </summary> ''' <param name="args">Command line args, unused.</param> Public Shared Sub Main(args As String()) Dim deck As New Deck(AllCards) Dim random As New Random() Dim calculator As New ProbabilityCalculator(AllCards) Dim player1 As New Player("Harry", calculator) Dim player2 As New Player("Joe", calculator) Dim game As New Game(deck, random, player1, player2) Console.WriteLine(game.Play()) Console.ReadLine() End Sub End Class ``` Imports System Imports System.Collections.Generic Imports System.Text ''' <summary> ''' Represents a single playing card, the combination of a suit (Spades, hearts, clubs, diamonds) ''' and a rank (Ace, two, three... Jack, Queen, King). ''' 表示一张纸牌,是花色(黑桃、红心、梅花、方块)的组合 ''' 还有一排(a,二,三……杰克,王后,国王)。 ''' Any particular card is worth a number of points, according to its rank. ''' 任何一张特定的纸牌,根据它的等级,值若干点数。 ''' In this simplified game, an Ace is always worth 1 points. ''' A two is with 2 points, three worth 3, and so on. ''' The face cards (Jack, Queen, King) are worth 10 points. ''' 在这个简化的游戏中,a总是值1分 '''2是2分,3是3分,以此类推 '''脸牌(杰克、皇后、国王)值10分。 ''' </summary> Public Class Card Public Enum Suit Spades Hearts Clubs Diamonds End Enum Public Enum Rank Ace = 1 Two = 2 Three = 3 Four = 4 Five = 5 Seven = 7 Eight = 8 Nine = 9 Ten = 10 Jack = 11 Queen = 12 King = 13 End Enum ReadOnly mSuit As Suit ReadOnly mRank As Rank Public Sub New(r As Rank, s As Suit) mSuit = s mRank = r End Sub ''' <summary> ''' Returns a human readable name of the card, for example "Ace of Spades", suitable for inclusion in ''' the game's console output. ''' 返回人类可读的纸牌名称,例如“黑桃a”,适合包含在游戏控制台输出中 ''' </summary> ''' <returns>Name of the card</returns> Public ReadOnly Property Description As String Get ' Return mRank + " of" + mSuit Return mRank.ToString + " of" + mSuit.ToString End Get End Property ''' <summary> ''' Returns the number of points that this card is worth, according to its rank. ''' 返回该牌值多少分,根据其分值。 ''' </summary> ''' <returns>Point value of this card.</returns> Public ReadOnly Property Points As Integer Get Return CType(mRank, Integer) End Get End Property Public Overrides Function ToString() As String Return Description End Function End Class `` ''' <summary> ''' Represents a collection of playing cards that will be dealt in the game. ''' 表示将在游戏中处理的纸牌集合。 ''' A fresh deck usually begins with the cards in an ordered sequence according to their suit and rank. ''' 一副新牌通常是按照牌的花色和等级顺序排列的。 ''' Before dealing cards to the players, the dealer should shuffle the deck, <see cref="System.Random" /> ''' 发牌前,发牌人应洗牌 ''' otherwise cards will be dealt in their original sequence. ''' 否则,牌将按原来顺序处理 ''' During the game, the dealer deals one card at a time, removing it from the top ''' of the deck, and adding it to the player's hand. ''' 在游戏中,发牌人一次发一张牌,把它从牌顶移开 并将其添加到玩家手上。 ''' </summary> ''' <remarks></remarks> Public Class Deck ''' <summary> ''' The cards remaining to be dealt ''' 剩下要处理的牌集合 ''' </summary> Private mCards As List(Of Card) ''' <summary> ''' Constructs a fresh deck with the specified cards in the given sequence ''' 按照给定的顺序用指定的牌组构造新的牌组 ''' </summary> ''' <param name="cards">@param cards cards</param> Public Sub New(cards As List(Of Card)) mCards = cards End Sub ''' <summary> ''' Randomizes the sequence of the cards within the deck. ''' 将牌堆中的牌的顺序随机化 ''' </summary> Public Sub Shuffle(random As Random) ' Keep a reference to the existing cards, then build a new list and copy ' 保持对现有卡片的引用,然后建立一个新的列表并复制 ' the cards over in a random sequence. ' 这些卡片是随机排列的。 Dim originalCards As List(Of Card) = mCards Dim shuffledCards As New List(Of Card) Dim numberOfCards As Integer = originalCards.Count For i As Integer = 0 To numberOfCards Dim nextCardIndex As Integer = random.Next(originalCards.Count) Dim nextCard As Card = originalCards(nextCardIndex) shuffledCards.Add(nextCard) Next mCards = shuffledCards End Sub ''' <summary> ''' Draws a card from the top of the deck, so that it can be added to a player's hand. ''' 从牌堆顶部抽一张牌,这样它就可以加到玩家手上。 ''' </summary> ''' <returns>Dealt card</returns> Public Function Deal() As Card Return mCards(0) End Function ''' <summary> ''' Returns the list of cards in the deck, in the sequence that they are going to be dealt. ''' 返回牌堆中纸牌的列表,按将要处理它们的顺序排列。 ''' </summary> ''' <returns>Cards cards in the deck</returns> Public ReadOnly Property Cards As List(Of Card) Get Return mCards End Get End Property End Class ``` ''' <summary> ''' Controller responsible for overall game loop. ''' 负责整个游戏循环的控制器 ''' </summary> Public Class Game Private mDeck As Deck Private mRandom As Random Private mPlayer1 As Player Private mPlayer2 As Player Public Sub New(deck As Deck, random As Random, player1 As Player, player2 As Player) mDeck = deck mRandom = random mPlayer1 = player1 mPlayer2 = player2 End Sub Public ReadOnly Property Deck As Deck Get Return mDeck End Get End Property Public ReadOnly Property Random As Random Get Return mRandom End Get End Property Public ReadOnly Property Player1 As Player Get Return mPlayer1 End Get End Property Public ReadOnly Property Player2 As Player Get Return mPlayer2 End Get End Property ''' <summary> ''' Main control loop. You an imagine this routine to reflect the actions of the dealer, who ''' coordinates gameplay. ''' 主要控制回路。你可以想象这个程序反映了协调游戏玩法的商人的行动。 ''' This simple game is played by two players. ''' The dealer is given a single fresh deck of cards, which he then shuffles. ''' Each player is dealt two cards. ''' Then each player takes their turn. ''' During their turn, a player can choose to "hit", which means they want to be dealt another card, ''' or to "stand", which means they will end their turn. ''' The player may "hit" as many times as they wish before ending their turn. ''' Once both players have taken their turn, the winner is determined. ''' The winner is the player with the greatest number of points without exceeding 21. ''' 这个简单的游戏是两个玩家玩的。发牌人拿到一副新的牌,然后洗牌。每人发两张牌。然后每个玩家轮流上场 '''在他们的回合中,玩家可以选择“hit”,这意味着他们想要发另一张牌,或者选择“stand”,这意味着他们将束他们的回合。 '''玩家可以在回合结束前按自己的意愿“命中”多少次。一旦两名选手轮流上场,胜者就已确定。得分最多且不超过21分者为胜者。 ''' </summary> ''' <returns>Output from the game</returns> Public Function Play() As String Dim output As New StringBuilder() ' The game begins... Dim hand1 = New Hand(mPlayer1) hand1.AddCard(mDeck.Deal()) hand1.AddCard(mDeck.Deal()) Dim hand2 = New Hand(mPlayer2) hand1.AddCard(mDeck.Deal()) hand1.AddCard(mDeck.Deal()) output.AppendFormat("{0} starts with {1}{2}", hand1.Player.Name, hand1.Description, Environment.NewLine) output.AppendFormat("{0} starts with {1}{2}", hand2.Player.Name, hand2.Description, Environment.NewLine) ' Players take their turns Dim hands As New List(Of Hand)({hand1, hand2}) For Each hand As Hand In hands Dim name As String = hand.Player.Name output.AppendFormat("{0}'s turn...{1}", name, Environment.NewLine) While (hand.Player.WantsToHit(hand.TotalPoints)) Dim dealt As Card = mDeck.Deal() output.AppendFormat("{0} hits: {1}{2}", name, dealt.Description, Environment.NewLine) hand.AddCard(dealt) End While If hand.TotalPoints > 21 Then output.AppendFormat("{0} bursts.{1}", name, Environment.NewLine) Else output.AppendFormat("{0} stands.{1}", name, Environment.NewLine) End If Next ' Determine the winner If hand1.Beats(hand2) Then output.AppendFormat("{0} WINS!{1}", hand1.Player.Name, Environment.NewLine) ElseIf hand2.Beats(hand1) Then output.AppendFormat("{0} WINS!{1}", hand2.Player.Name, Environment.NewLine) Else output.AppendFormat("It's a DRAW!{0}", Environment.NewLine) End If Return output.ToString() End Function End Class ``` ''' <summary> ''' Represents the collection of cards that have been dealt to a player. ''' 表示已分发给玩家的纸牌集合 ''' </summary> Public Class Hand ''' <summary> ''' The cards currently held in this hand ''' </summary> Private mCards As List(Of Card) ''' <summary> ''' The player to whom this hand belongs ''' </summary> Private mPlayer As Player ''' <summary> ''' Constructs a new hand for the specified player. ''' </summary> ''' <param name="player">The player to whom this hand belongs</param> Public Sub New(player As Player) mPlayer = player mCards = New List(Of Card)() End Sub ''' <summary> ''' Returns the player that this hand belongs to. ''' </summary> ''' <returns>player</returns> Public ReadOnly Property Player As Player Get Return mPlayer End Get End Property ''' <summary> ''' Adds a card to the hand ''' </summary> ''' <param name="card">the card to be added</param> Public Sub AddCard(card As Card) mCards.Add(card) End Sub ''' <summary> ''' Returns the total points for this hand by adding up the points of each card. ''' </summary> ''' <returns>total points</returns> Public ReadOnly Property TotalPoints As Integer Get Dim points As Integer = 0 For i As Integer = 0 To (mCards.Count - 1) points += mCards(i).Points Next Return points End Get End Property ''' <summary> ''' Determines whether this hand is better than the other player's hand. ''' 确定这手牌是否比其他玩家的那手牌好 ''' In general, the winning hand is the hand with the greatest number of points. ''' 一般来说,获胜的手是得分最多的手 ''' But, if the hand exceeds 21 then it is a "bust" - the other player wins. ''' 但是,如果这只手超过21,那么它就是一个“半身像”——另一个玩家赢了 ''' If both players bust, or if their total points are the same, then it is a draw. ''' 如果双方球员都失败了,或者他们的总得分相同,那么就是平局 ''' </summary> ''' <param name="other">the hand to compare against</param> ''' <returns>True, if this is a better hand than the specified other hand</returns> Public Function Beats(other As Hand) As Boolean Dim myScore As Integer = TotalPoints If myScore > 21 Then Return False End If Dim otherScore As Integer = other.TotalPoints If otherScore > myScore Then Return False End If Return True End Function ''' <summary> ''' Returns a formatted description of the cards in the hand, suitable for screen output ''' </summary> ''' <returns>Description of the hand</returns> Public ReadOnly Property Description As String Get Dim desc As New StringBuilder() desc.Append(mCards.Count) desc.Append(" cards: ") Dim first As Boolean = True For Each card As Card In mCards If Not first Then desc.Append(", ") End If desc.Append(card.Description) first = False Next desc.Append(".") Return desc.ToString() End Get End Property End Class ``` ''' <summary> ''' Represents a player, and their decision making logic for whether to ''' "hit" or "stand" ''' </summary> Public Class Player ''' <summary> ''' A friendly name that identifies the player. ''' 一个识别玩家的友好名字 ''' </summary> Private mName As String ''' <summary> ''' Used for calculating probability of bust ''' 用于计算破产概率 ''' </summary> Private mProbabilityCalculator As ProbabilityCalculator ''' <summary> ''' Constructor. ''' </summary> ''' <param name="name">player's name</param> ''' <param name="probabilityCalculator">for calculating probability of bust</param> ''' <remarks></remarks> Public Sub New(name As String, probabilityCalculator As ProbabilityCalculator) mName = name mProbabilityCalculator = probabilityCalculator End Sub ''' <summary> ''' Returns the player's name ''' </summary> ''' <returns>name</returns> Public ReadOnly Property Name As String Get Return mName End Get End Property ''' <summary> ''' Determines whether the player would like to "hit" (have another card dealt to their hand), ''' or "stand" (end their turn). ''' In this simple implementation, the player's strategy is to hit, so long as they are more likely ''' to increase their points than they are to bust. ''' If their current points are at 21, they should always stay ''' If their current points are at 10 or below, they can never bust, so they should always hit ''' For points in between, they will hit so long as the probability of the next draw causing a bust is less ''' than 50%. ''' 决定玩家是想“击中”(手上有另一张牌),还是“站着”(结束他们的回合)。在这个简单的实现中,玩家的策略是命中, ''' 只要他们更有可能增加他们的点数而不是失败。如果他们现在的分数是21分,他们应该一直保持下去 '''如果他们现在的点数是10点或以下,他们永远不会破产,所以他们应该总是击中中间的点数,只要下一次平局导致破产的概率小于50%,他们就会击中。 ''' </summary> ''' <param name="currentPoints">The total of the cards currently held by this player</param> ''' <remarks>True if the players wants to "hit", false if they want to "stand".</remarks> Public Function WantsToHit(currentPoints As Integer) If currentPoints >= 21 Then Return False ElseIf currentPoints <= 10 Then Return True Else Return mProbabilityCalculator.CalculateProbability(currentPoints) < 0.5 End If End Function End Class ``` ''' <summary> ''' Used by the player's hit/stand decision making, to determine the probability of busting if ''' they deal another card. ''' 用于玩家的命中/立场决策,以确定如果他们发另一张牌失败的概率 ''' </summary> Public Class ProbabilityCalculator ''' <summary> ''' All possible cards ''' </summary> Private mFullDeck As List(Of Card) Public Sub New(fullDeck As List(Of Card)) mFullDeck = fullDeck End Sub ''' <summary> ''' Determines the probability of a "bust" if the players deals one more card into their hand. ''' A "bust" occurs if the next card takes their total over 21. ''' 确定一个“破产”的概率,如果玩家在他们的手上多出一张牌。如果下一张牌的总数超过21,就会发生“破产” ''' ''' The probability is simulated as follows: ''' Consider all possible cards that might be dealt next if the player chooses to "hit". ''' (Since "card counting" is a no-no in Blackjack, we imagine that *any* of the cards from a ''' normal full deck could be dealt next. ie. don't exclude cards that have already been dealt). ''' For each possibility, determine the total points that would be achieved if that card ''' were added to the player's hand, and decide whether or not it is a bust. ''' The probability of a bust is the percentage of all the combinations tried that resulted in a bust. ''' 概率模拟如下: 考虑一下,如果玩家选择“命中”,接下来可能要发的所有牌。 '''(由于“数牌”在21点游戏中是不允许的,我们认为接下来可以处理任何一张普通的整副牌中的牌。ie。不要排除已经发过的牌)。 '''对于每一种可能性,确定如果那张牌可以获得的总积分 被添加到玩家手上,并决定它是否是一个破产。 '''破产的概率是所有尝试过的导致破产的组合的百分比。 ''' ''' For example, if the player's current total is 12, then dealing any card worth 10 points ''' will result in a bust. Out of the 52 cards in a deck, 16 of them are worth 10 points (the Tens, Jacks, ''' Queens and Kings of Spades, Hearts, Clubs and Diamonds). So, the probability of a bust ''' is 0.3077 (30.77%), which is 16 divided by 52. ''' Similarly, if the player's current total is 19, there are 44 possible cards that will result in ''' a bust (everything except the aces and twos), and so the probability is 0.8462. ''' 例如,如果玩家当前的总数是12,那么处理任何值10分的牌 会导致破产。在一副牌中的52张牌中,16张值10分(10,j,黑桃、红桃、梅花和方块的王后和国王)。 ''' 因此,破产的概率是0.3077(30.77%)也就是16除以52。同样的,如果玩家当前的总数是19,那么有44张可能导致失败的牌(除了a和2以外的所有牌),所以概率是0.8462。 ''' </summary> ''' <param name="currentPoints">the total points for the player's current hand</param> ''' <returns>probability of a bust if one more card is dealt (0.5f = 50%)</returns> Public Function CalculateProbability(currentPoints As Integer) As Decimal ' Problem: we can't calculate the probability if we don't have any cards to simulate with. ' This shouldn't happen, but to prevent potential crashes, we'll return 50% ' 问题:如果我们没有卡片来模拟,我们就无法计算概率。这不应该发生,但为了防止潜在的崩溃,我们将返回50% If mFullDeck.Count = 0 Then Return 0.5 End If Dim numberOfBusts As Integer = 0 Dim numberOfNonBusts As Integer = 0 For Each card As Card In mFullDeck Dim potentialPoints = currentPoints + card.Points If (potentialPoints > 21) Then numberOfBusts += 1 Else numberOfNonBusts += 1 End If Next Return numberOfBusts / CType(numberOfNonBusts, Decimal) End Function End Class ``` ``` ```
Catch the Bus!
Problem Description ACM needs to deliver marketing materials to one of their clients. Both ACM and the client employ students to make such deliveries. And these students use public buses to move throughout the city. Sometimes, it is necessary to pass the materials as fast as possible. You are given bus timetables and your task is to find the fastest way for two students to meet at some stop. The place of the meeting is not important, they only need to meet as early as possible. Students may change between any two bus routes at stops that are common for both routes. At least two minutes are needed for every such change. No additional time is necessary to get on the first bus or to meet the other student in the target stop. Input The input contains a sequence of several scenarios, the sequence is terminated by a line containing negative number. Each scenario begins with a non-negative integer L, the number of bus routes that operate in the city (L ≤ 1000). Every route is then described by two lines. The first line contains names of stops that the bus runs through. Between each consecutive stops, there is a non-negative integer specifying the number of minutes required to travel between these stops with the given bus. The last stop is followed by a negative number. The second line of each bus route contains non-negative integers separated with spaces. The first integer H gives the number of buses that depart the initial stop in every hour (H ≤ 60). The remaining H integers are always distinct and sorted ascendingly, they list the minutes of departure (between 0 and 59). The timetable repeats every hour. For example, if the second line says “2 00 30”, the buses leave the initial stop at 12:00, 12:30, 13:00, 13:30, 14:00, etc. After the description of routes, there are two lines that specify the initial position of students. Each of them will contain time in a standard 24-hour format (one or two digits for hours, colon, and two digits for minutes) and a stop name. All numbers, times, and stop names will be separated with a single space. Stop names are case-sensitive and may be composed only from lower-case and upper-case letters, their length will not exceed 30 characters. The total number of stops will be at most 1000, the number of stops on a single route will not exceed 100. The time between any two consecutive stops will be at most one hour. The routes are considered one-way, if they operate in both directions, they will be given as two separate routes. A route may run through the same stop several times. Output For each test scenario, output a single line containing the earliest possible time the students can meet at any of the stops. The time must appear in the standard 24-hour format, hours given as a number between 0 and 23, then colon and minutes between 0 and 59. For hour values less than 10, only one digit must be used. Be aware of the fact that both students start their trip on the same day but may meet on another day, if the required time exceeds midnight. If the students are not able to meet in some scenario, output the words “No connection” instead of the time. Sample Input 4 Hradcanska 2 Malostranska 2 Staromestska 2 Mustek 1 Muzeum -1 10 00 06 12 18 24 30 36 42 48 54 Muzeum 1 Mustek 2 Staromestska 2 Malostranska 2 Hradcanska -1 10 03 09 15 21 27 33 39 45 51 57 Andel 2 Karlovo 1 Narodni 2 Mustek 2 Florenc -1 6 00 10 20 30 40 50 Florenc 2 Mustek 2 Narodni 3 Karlovo 1 Andel -1 6 02 12 22 32 42 52 12:00 Hradcanska 12:11 Andel 1 Hradcanska 2 Malostranska 2 Staromestska 2 Mustek 1 Muzeum 2 Hradcanska -1 10 00 06 12 18 24 30 36 42 48 54 12:00 Mustek 12:00 Andel -1 Sample Output 12:20 No connection
Jezzball 的问题
Problem Description “JezzBall is a computer game in which red-and-white ‘atoms’ bounce about a rectangular field of play. The player advances to later levels (with correspondingly higher numbers of atoms and lives) by containing the atoms in progressively smaller spaces, until at least 75% of the area is blocked off.” (wikipedia.org) The picture to the right is a screenshot from the original game, where the player has already covered some space (the black part). In this problem we will consider a slightly different, non-discrete, version of the game. That is, while the length unit is still pixels, you should treat them as non-discrete in the sense that all objects can be at non-integer coordinates and all movements are continuous. The size of the playing field will be 1024 × 768 pixels. The atoms that bounce around will be infinitely thin (and not round balls like in the screenshot). The atoms will move at a constant speed and only change direction when hitting the edge of the playing field (x-coordinate 0 and 1024 or y-coordinate 0 and 768), where they bounce without loss of energy. The atoms do not hit each other. The player can divide the playing field in two by shooting a horizontal or vertical ray from (in this problem) a fixed point on the playing field. The ray will then extend in both directions simultaneously (up and down for vertical rays, or left and right for horizontal rays) at a uniform speed (in this problem always 200 pixels per second). The rays will also be infinitely thin. If no atom touches any part of the ray while it’s still being extended, the field has successfully been divided. Otherwise the player loses a life. If an atom touches the endpoint of an extending edge, this will not be counted as a hit. Also, if an atom hits the ray at the same instant it has finished extending, this will also not count as a hit. Write a program that determines the minimum time the player must wait before he can start extending a ray so that an atom will not hit it before the ray has been completed. Input Each test case starts with a line containing a single integer n, the number of atoms (1 ≤ n ≤ 10). Then follows a line containing two integers, x and y, the position where the two ray ends will start extending from (0 < x < 1024, 0 < y < 768). Then n lines follow, each containing four integers, x, y, vx and vy describing the initial position and speed of an atom (0 < x < 1024, 0 < y < 768, 1 ≤ |vx| ≤ 200, 1 ≤ |vy| ≤ 200). The speed of the atom in the x direction is given by vx, and the speed in the y direction is given by vy. All positions in each input will be distinct. The input is terminated by a case where n = 0, which should not be processed. There will be at most 25 test cases. Output For each test case, output the minimum time (with exactly 5 decimal digits) until the player can extend either a horizontal or vertical ray without an atom colliding with it while it is being drawn. The input will be constructed so that the first time this occurs will be during an open interval at least 10-5 seconds long. If no such interval is found during the first 10000 seconds, output “Never” (without quotes). Sample Input 3 700 420 360 290 170 44 900 150 -53 20 890 100 130 -100 4 10 10 1 1 192 144 513 385 192 144 1023 767 -192 -144 511 383 -192 -144 0 Sample Output 2.80094 Never
Worms 请问怎么做
Problem Description Biologists are studying a certain, interesting kind of worm. Each worm can be seen as a line of cells of different types. When a worm is born, it only consists of a single cell. Every day, exactly 1 cell of the entire worm will grow and change into 2 cells. It is rather easy to determine the age of any such worm, since it's simply one less than the number of cells the worm has. During a worm's growth, a cell does not change into any 2 arbitrary cells; each worm has a set of ``growth rules" (encoded in its DNA) that it obeys. A growth rule can be expressed as A --> BC , where A , B and C are uppercase letters (with letters A-T), representing different types of the worm's cells. The rule A --> BC means that in one day, any single cell A can be grown into the 2 adjacent cells BC , in that order. Note that the rule I --> JK is different from the rule I --> KJ . Different worms may have a different set of growth rules. The worms have now thrown the scientists for a loop. Due to some unknown reason, some worms have mutated into a new kind of specimen. This new kind of worm has the exact same properties, except that during its growth, multiple parts of its body can grow at the same time. That is, every day any (at least one, at most all) of its cells can grow; each cell that grows will grow into exactly 2 cells (obeying growth rules similar to their older cousins). As a result of the mutation, it is no longer trivial to determine the age of a worm. In fact, the exact age of some worms cannot be determined. As a simple example, if a worm has growth rules: A --> BC , B --> AC , C --> AB , and the worm's current cell structure is ACAB , the worm can be either 2 or 3 days old ( A --> BC --> ACAB , or A --> BC --> ACC --> ACAB ). Your task is to find out the youngest possible age of any given mutated worm. Input There will be multiple worms for examination in the input. Each worm's data set begins with an integer N ( 1<=N<=80 ), the number of growth rules. The next N lines each contain 3 uppercase letters (with letters A-T), representing a growth rule for the current worm. The 1st cell can grow into (and be replaced by) the 2nd and 3rd cells, in order, during the growth process. That is, the line: ABC means A --> BC is a growth rule for the current worm. The next (and last) line of each worm's data set contains a string of uppercase letters (with letters A-T). This line represents the current cell structure of the worm. Every worm in the input will have at least 1 and at most 50 cells. The last worm will be followed by a line with a single 0. Output For each worm, if the worm can be grown into the given cell sequence with the given growth rule set (starting with any arbitrary single cell), then print the minimum age, in days, of the worm, as an integer on its own line. If the worm cannot be grown into the given cell sequence with the given rule set (starting with any arbitrary single cell), then simply print the number `-1' on its own line. Print no blank lines between outputs. Sample Input 3 ABC BAC CAB ACAB 1 AAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 2 PAA AAA AAAAAAAAAAAAAAAP 1 BAB AAAAAAB 0 Sample Output 2 6 -1 6
相见恨晚的超实用网站
相见恨晚的超实用网站 持续更新中。。。
Java学习的正确打开方式
在博主认为,对于入门级学习java的最佳学习方法莫过于视频+博客+书籍+总结,前三者博主将淋漓尽致地挥毫于这篇博客文章中,至于总结在于个人,实际上越到后面你会发现学习的最好方式就是阅读参考官方文档其次就是国内的书籍,博客次之,这又是一个层次了,这里暂时不提后面再谈。博主将为各位入门java保驾护航,各位只管冲鸭!!!上天是公平的,只要不辜负时间,时间自然不会辜负你。 何谓学习?博主所理解的学习,它是一个过程,是一个不断累积、不断沉淀、不断总结、善于传达自己的个人见解以及乐于分享的过程。
程序员必须掌握的核心算法有哪些?
由于我之前一直强调数据结构以及算法学习的重要性,所以就有一些读者经常问我,数据结构与算法应该要学习到哪个程度呢?,说实话,这个问题我不知道要怎么回答你,主要取决于你想学习到哪些程度,不过针对这个问题,我稍微总结一下我学过的算法知识点,以及我觉得值得学习的算法。这些算法与数据结构的学习大多数是零散的,并没有一本把他们全部覆盖的书籍。下面是我觉得值得学习的一些算法以及数据结构,当然,我也会整理一些看过...
有哪些让程序员受益终生的建议
从业五年多,辗转两个大厂,出过书,创过业,从技术小白成长为基层管理,联合几个业内大牛回答下这个问题,希望能帮到大家,记得帮我点赞哦。 敲黑板!!!读了这篇文章,你将知道如何才能进大厂,如何实现财务自由,如何在工作中游刃有余,这篇文章很长,但绝对是精品,记得帮我点赞哦!!!! 一腔肺腑之言,能看进去多少,就看你自己了!!! 目录: 在校生篇: 为什么要尽量进大厂? 如何选择语言及方...
大学四年自学走来,这些私藏的实用工具/学习网站我贡献出来了
大学四年,看课本是不可能一直看课本的了,对于学习,特别是自学,善于搜索网上的一些资源来辅助,还是非常有必要的,下面我就把这几年私藏的各种资源,网站贡献出来给你们。主要有:电子书搜索、实用工具、在线视频学习网站、非视频学习网站、软件下载、面试/求职必备网站。 注意:文中提到的所有资源,文末我都给你整理好了,你们只管拿去,如果觉得不错,转发、分享就是最大的支持了。 一、电子书搜索 对于大部分程序员...
linux系列之常用运维命令整理笔录
本博客记录工作中需要的linux运维命令,大学时候开始接触linux,会一些基本操作,可是都没有整理起来,加上是做开发,不做运维,有些命令忘记了,所以现在整理成博客,当然vi,文件操作等就不介绍了,慢慢积累一些其它拓展的命令,博客不定时更新 free -m 其中:m表示兆,也可以用g,注意都要小写 Men:表示物理内存统计 total:表示物理内存总数(total=used+free) use...
比特币原理详解
一、什么是比特币 比特币是一种电子货币,是一种基于密码学的货币,在2008年11月1日由中本聪发表比特币白皮书,文中提出了一种去中心化的电子记账系统,我们平时的电子现金是银行来记账,因为银行的背后是国家信用。去中心化电子记账系统是参与者共同记账。比特币可以防止主权危机、信用风险。其好处不多做赘述,这一层面介绍的文章很多,本文主要从更深层的技术原理角度进行介绍。 二、问题引入 假设现有4个人...
程序员接私活怎样防止做完了不给钱?
首先跟大家说明一点,我们做 IT 类的外包开发,是非标品开发,所以很有可能在开发过程中会有这样那样的需求修改,而这种需求修改很容易造成扯皮,进而影响到费用支付,甚至出现做完了项目收不到钱的情况。 那么,怎么保证自己的薪酬安全呢? 我们在开工前,一定要做好一些证据方面的准备(也就是“讨薪”的理论依据),这其中最重要的就是需求文档和验收标准。一定要让需求方提供这两个文档资料作为开发的基础。之后开发...
网页实现一个简单的音乐播放器(大佬别看。(⊙﹏⊙))
今天闲着无事,就想写点东西。然后听了下歌,就打算写个播放器。 于是乎用h5 audio的加上js简单的播放器完工了。 演示地点演示 html代码如下` music 这个年纪 七月的风 音乐 ` 然后就是css`*{ margin: 0; padding: 0; text-decoration: none; list-...
Python十大装B语法
Python 是一种代表简单思想的语言,其语法相对简单,很容易上手。不过,如果就此小视 Python 语法的精妙和深邃,那就大错特错了。本文精心筛选了最能展现 Python 语法之精妙的十个知识点,并附上详细的实例代码。如能在实战中融会贯通、灵活使用,必将使代码更为精炼、高效,同时也会极大提升代码B格,使之看上去更老练,读起来更优雅。
数据库优化 - SQL优化
以实际SQL入手,带你一步一步走上SQL优化之路!
2019年11月中国大陆编程语言排行榜
2019年11月2日,我统计了某招聘网站,获得有效程序员招聘数据9万条。针对招聘信息,提取编程语言关键字,并统计如下: 编程语言比例 rank pl_ percentage 1 java 33.62% 2 cpp 16.42% 3 c_sharp 12.82% 4 javascript 12.31% 5 python 7.93% 6 go 7.25% 7 p...
通俗易懂地给女朋友讲:线程池的内部原理
餐盘在灯光的照耀下格外晶莹洁白,女朋友拿起红酒杯轻轻地抿了一小口,对我说:“经常听你说线程池,到底线程池到底是个什么原理?”
《奇巧淫技》系列-python!!每天早上八点自动发送天气预报邮件到QQ邮箱
将代码部署服务器,每日早上定时获取到天气数据,并发送到邮箱。 也可以说是一个小型人工智障。 知识可以运用在不同地方,不一定非是天气预报。
经典算法(5)杨辉三角
杨辉三角 是经典算法,这篇博客对它的算法思想进行了讲解,并有完整的代码实现。
英特尔不为人知的 B 面
从 PC 时代至今,众人只知在 CPU、GPU、XPU、制程、工艺等战场中,英特尔在与同行硬件芯片制造商们的竞争中杀出重围,且在不断的成长进化中,成为全球知名的半导体公司。殊不知,在「刚硬」的背后,英特尔「柔性」的软件早已经做到了全方位的支持与支撑,并持续发挥独特的生态价值,推动产业合作共赢。 而对于这一不知人知的 B 面,很多人将其称之为英特尔隐形的翅膀,虽低调,但是影响力却不容小觑。 那么,在...
腾讯算法面试题:64匹马8个跑道需要多少轮才能选出最快的四匹?
昨天,有网友私信我,说去阿里面试,彻底的被打击到了。问了为什么网上大量使用ThreadLocal的源码都会加上private static?他被难住了,因为他从来都没有考虑过这个问题。无独有偶,今天笔者又发现有网友吐槽了一道腾讯的面试题,我们一起来看看。 腾讯算法面试题:64匹马8个跑道需要多少轮才能选出最快的四匹? 在互联网职场论坛,一名程序员发帖求助到。二面腾讯,其中一个算法题:64匹...
面试官:你连RESTful都不知道我怎么敢要你?
干货,2019 RESTful最贱实践
刷了几千道算法题,这些我私藏的刷题网站都在这里了!
遥想当年,机缘巧合入了 ACM 的坑,周边巨擘林立,从此过上了"天天被虐似死狗"的生活… 然而我是谁,我可是死狗中的战斗鸡,智力不够那刷题来凑,开始了夜以继日哼哧哼哧刷题的日子,从此"读题与提交齐飞, AC 与 WA 一色 ",我惊喜的发现被题虐既刺激又有快感,那一刻我泪流满面。这么好的事儿作为一个正直的人绝不能自己独享,经过激烈的颅内斗争,我决定把我私藏的十几个 T 的,阿不,十几个刷题网...
SQL-小白最佳入门sql查询一
不要偷偷的查询我的个人资料,即使你再喜欢我,也不要这样,真的不好;
JavaScript 为什么能活到现在?
作者 | 司徒正美 责编 |郭芮 出品 | CSDN(ID:CSDNnews) JavaScript能发展到现在的程度已经经历不少的坎坷,早产带来的某些缺陷是永久性的,因此浏览器才有禁用JavaScript的选项。甚至在jQuery时代有人问出这样的问题,jQuery与JavaScript哪个快?在Babel.js出来之前,发明一门全新的语言代码代替JavaScript...
项目中的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 初学者走出困境、快速成长。希望我的经验能真正帮到你
Python 编程开发 实用经验和技巧
Python是一门很灵活的语言,也有很多实用的方法,有时候实现一个功能可以用多种方法实现,我这里总结了一些常用的方法和技巧,包括小数保留指定位小数、判断变量的数据类型、类方法@classmethod、制表符中文对齐、遍历字典、datetime.timedelta的使用等,会持续更新......
吐血推荐珍藏的Visual Studio Code插件
作为一名Java工程师,由于工作需要,最近一个月一直在写NodeJS,这种经历可以说是一部辛酸史了。好在有神器Visual Studio Code陪伴,让我的这段经历没有更加困难。眼看这段经历要告一段落了,今天就来给大家分享一下我常用的一些VSC的插件。 VSC的插件安装方法很简单,只需要点击左侧最下方的插件栏选项,然后就可以搜索你想要的插件了。 下面我们进入正题 Material Theme ...
实战:如何通过python requests库写一个抓取小网站图片的小爬虫
有点爱好的你,偶尔应该会看点图片文字,最近小网站经常崩溃消失,不如想一个办法本地化吧,把小照片珍藏起来! 首先,准备一个珍藏的小网站,然后就可以开始啦! 第一步 我们先写一个获取网站的url的链接,因为url常常是由page或者,其他元素构成,我们就把他分离出来,我找到的网站主页下有图片区 图片区内有标题页,一个标题里有10张照片大概 所以步骤是: 第一步:进入图片区的标题页 def getH...
“狗屁不通文章生成器”登顶GitHub热榜,分分钟写出万字形式主义大作
一、垃圾文字生成器介绍 最近在浏览GitHub的时候,发现了这样一个骨骼清奇的雷人项目,而且热度还特别高。 项目中文名:狗屁不通文章生成器 项目英文名:BullshitGenerator 根据作者的介绍,他是偶尔需要一些中文文字用于GUI开发时测试文本渲染,因此开发了这个废话生成器。但由于生成的废话实在是太过富于哲理,所以最近已经被小伙伴们给玩坏了。 他的文风可能是这样的: 你发现,...
程序员:我终于知道post和get的区别
是一个老生常谈的话题,然而随着不断的学习,对于以前的认识有很多误区,所以还是需要不断地总结的,学而时习之,不亦说乎
《程序人生》系列-这个程序员只用了20行代码就拿了冠军
你知道的越多,你不知道的越多 点赞再看,养成习惯GitHub上已经开源https://github.com/JavaFamily,有一线大厂面试点脑图,欢迎Star和完善 前言 这一期不算《吊打面试官》系列的,所有没前言我直接开始。 絮叨 本来应该是没有这期的,看过我上期的小伙伴应该是知道的嘛,双十一比较忙嘛,要值班又要去帮忙拍摄年会的视频素材,还得搞个程序员一天的Vlog,还要写BU...
加快推动区块链技术和产业创新发展,2019可信区块链峰会在京召开
11月8日,由中国信息通信研究院、中国通信标准化协会、中国互联网协会、可信区块链推进计划联合主办,科技行者协办的2019可信区块链峰会将在北京悠唐皇冠假日酒店开幕。   区块链技术被认为是继蒸汽机、电力、互联网之后,下一代颠覆性的核心技术。如果说蒸汽机释放了人类的生产力,电力解决了人类基本的生活需求,互联网彻底改变了信息传递的方式,区块链作为构造信任的技术有重要的价值。   1...
相关热词 c# 二进制截断字符串 c#实现窗体设计器 c#检测是否为微信 c# plc s1200 c#里氏转换原则 c# 主界面 c# do loop c#存为组套 模板 c# 停掉协程 c# rgb 读取图片
立即提问