狗gou富贵
狗gou富贵
是一個人
关注数: 4
粉丝数: 15
发帖数: 238
关注贴吧数: 25
换了台电脑 以前可以跑的程序现在报错了 求助
初学者 想知道为什么这个else不同的缩进会有不同的结果 以前学过c和c++ 刚接触python 发现else不同的缩进会有不同的结果 以前没遇到过 求教
老萌新回归 06年的玩家 十二年啦 求推荐现在的职业和区 老萌新回归 06年的玩家 十二年啦 求推荐现在的职业和区 能氪金 求一起玩的朋友啊
多机调度问题 用c++实现 离散数学的多机调度,用c++写,并用伪代码解释有 2 台机器 c1, c2; 6 项任务 t1, t2, …, t6. 每项任务的加工时间分别为 l(t1)=l(t3)=l(t5)=l(t6)=1, l(t2)=l(t4)=2 任务之间的顺序约束是: 任务 t3 只有在 t6 和 t5 完成之后才能开始加工; 任务 t2 只有在 t6, t5 和 t4 都完成后才能开始加工; 任务 t1 只有在 t3 和 t2 完成之后才能开始加工. 调度:任务安排在机器上加工的方案 截止时间:开始时刻 0,最后停止加工机器的停机时刻
多机调度问题 用c语言实现 离散数学的多机调度,用c语言写,并用伪代码解释有 2 台机器 c1, c2; 6 项任务 t1, t2, …, t6. 每项任务的加工时间分别为 l(t1)=l(t3)=l(t5)=l(t6)=1, l(t2)=l(t4)=2 任务之间的顺序约束是: 任务 t3 只有在 t6 和 t5 完成之后才能开始加工; 任务 t2 只有在 t6, t5 和 t4 都完成后才能开始加工; 任务 t1 只有在 t3 和 t2 完成之后才能开始加工. 调度:任务安排在机器上加工的方案 截止时间:开始时刻 0,最后停止加工机器的停机时刻
书里的程序 写出运行结果 但是编译器报错 #include <iostream> using namespace std; class A { int x; public: A(int a = 0, int b = 2) :x(a) {} A &operator=(A& o) { x = o.x; cout << "In A=(A&),x=" << x << endl; return *this; } int getx() { return x; } A& operator=(A &&o) = default; }; class B :public A { int y; public: B(int a = 0, int b = 0) :A(a), y(b) {} B& operator =(B& o) { A::operator=(o); cout << "In B=(B&),x=" << getx() << "\ty=" << y << endl; return *this; } }; int main() { B b, b1(1, 2); b = b1; b1 = std::move(b); }
关于c++类的定义和使用的 萌新求教 老司机快来带带我 1.请将程序补充完整,使程序的输出结果为: 3.140000,10,c++ #include<iostream> using namespace std; class Test{ public: int getMid(); string formatData(); private: int mid; float mfd; int &mrd; const char* mcd; }; int Test::getMid() { return mid; } string Test::formatData() { char buf[20]; sprintf(buf, "%f,%d,%s", mfd, mrd, mcd); return buf; } int main() { int m = 10; Test test(m); cout << test.formatData() << endl; return 0; } 修改程序中的错误,使程序的输出结果为: 10 #include<iostream> using namespace std; class Test{ Test(int); private: int mid; public: string formatData(); }; Test::Test(int mid) { mid = mid; } string Test::formatData() { char buf[20]; sprintf(buf, "%d", mid); return buf; } int main() { int m = 10; Test test(m); cout << formatData() << endl; return 0; }
萌新求教 1.请将程序补充完整,使程序的输出结果为: 3.140000,10,c++ #include<iostream> using namespace std; class Test{ public: int getMid(); string formatData(); private: int mid; float mfd; int &mrd; const char* mcd; }; int Test::getMid() { return mid; } string Test::formatData() { char buf[20]; sprintf(buf, "%f,%d,%s", mfd, mrd, mcd); return buf; } int main() { int m = 10; Test test(m); cout << test.formatData() << endl; return 0; } 修改程序中的错误,使程序的输出结果为: 10 #include<iostream> using namespace std; class Test{ Test(int); private: int mid; public: string formatData(); }; Test::Test(int mid) { mid = mid; } string Test::formatData() { char buf[20]; sprintf(buf, "%d", mid); return buf; } int main() { int m = 10; Test test(m); cout << formatData() << endl; return 0; }
求教 为什么我在一个项目里定义完类并使用可以正常运行 求教 为什么我在一个项目里定义完一个类并使用可以正常运行 把类的定义和使用分开成两个file 比如一个叫main.cpp 一个叫main2.cpp 其余部分完全不变 只在main2.cpp开头加#include "main.cpp" 编译器就会报错
萌新 想买一个耳机 不知哪个好 现在选了几个 死丢丢2 s 萌新 想买一个耳机 不知哪个好 现在选了几个 死丢丢2 sony abn 魔声的elements on ear 求分析 求安利
萌新求教 救命啊 3. 给出程序的输出结果,如有错误,请改正 #include <iostream> #include<string> using namespace std; void print(const string &s1) { cout << "call for void print(const string &s1)" << endl; cout << s1; } void print(string &s1) { cout << "call for void print(string &s1)" << endl; cout << s1; } void print(string s1) { cout << "call for void print(string s1)" << endl; cout << s1; } int main() { print("world"); return 0; } 为什么const string &s1会和string s1一样?导致print过载 4. 给出程序的输出结果,如有错误,请改正 #include <iostream> using namespace std; float temp; float area1(float r) { temp = r*r*3; return temp; } float& area2(float r) { temp = r*r*3; return temp; } int main() { float a1 = area1(5.0); float& a2 = area1(5.0); float& a3 = area2(5.0); float a4 = area1(4) = 10; float a5 = area2(4) = 20; cout << a1 << endl; cout << a2 << endl; cout << a3 << endl; cout << a4 << endl; cout << a5 << endl; return 0; }
萌新求教1. 指出程序中的错误,说明原因,并指出哪些顶层co 萌新求教 1. 指出程序中的错误,说明原因,并指出哪些顶层const,哪些是底层const #include <iostream> #include<string> using namespace std; int main(){ string *pstr = "c++"; const string ss= "Java" + *pstr; const string ss= "Java"; char str[] = "Python"; const char *const ps = str; str[4] = 'e'; ps[1] = 'o'; pstr = ss; string &const rs = ss; return 0; } 2. 给出程序的输出结果,如有错误,请改正 #include <iostream> #include<string> using namespace std; void print(int x = 3) { cout << ”call for void print(int x = 3)” << endl; cout << "x = " << x << endl; } void print(string s1 = "hello", string s2) { cout << “call for void print(string s1 = ”hello“, string s2)“ << endl; cout << s1 + "," + s2; } int main() { print(5); print(); print("world"); print(); return 0; } 3. 给出程序的输出结果,如有错误,请改正 #include <iostream> #include<string> using namespace std; void print(const string &s1) { cout << "call for void print(const string &s1)" << endl; cout << s1; } void print(string &s1) { cout << "call for void print(string &s1)" << endl; cout << s1; } void print(string s1) { cout << "call for void print(string s1)" << endl; cout << s1; } int main() { print("world"); return 0; } 4. 给出程序的输出结果,如有错误,请改正 #include <iostream> using namespace std; float temp; float area(float r) { temp = r*r*3; return temp; } float& area(float r) { temp = r*r*3; return temp; } int main() { float a1 = fn1(5.0); float& a2 = fn1(5.0); float& a3 = fn2(5.0); float a4 = fn1(4) = 10; float a5 = fn2(4) = 20; cout << a1 << endl; cout << a2 << endl; cout << a3 << endl; cout << a4 << endl; cout << a5 << endl; return 0; }
萌新求教 这个程序运行后 只能使用一次 基于链表结构实现一个简单的通讯录管理系统,实现通讯录的简单电子化。该系统具有增加新纪录,修改原记录,删除原纪录,根据姓名查找和查看所有记录等功能。 #include<bits/stdc++.h> using namespace std; struct stud_node{ char name[20]; struct stud_node *next; }; struct stud_node * InsertDoc(struct stud_node * head, struct stud_node *stud); struct stud_node * DeleteDoc(struct stud_node * head, char *name); struct stud_node * FindDoc(struct stud_node * head,char *name); int Print_Stu_Doc(struct stud_node * head); int main() { struct stud_node *head,*p; int choice; char name[20]; int size = sizeof(struct stud_node); head=nullptr; cout<<"1.增加新记录\n"<<"2.修改原记录\n"<<"3.删除原纪录\n"<<"4.根据姓名查找\n"<<"5.查看所有记录\n"<<"6.out\n"<<endl; cin>>choice; switch(choice) { case 1: printf("增加人员的信息"); printf("姓名:"); scanf("%s",name); p = (struct stud_node *) malloc(size); strcpy(p->name, name); p->next=nullptr; head=InsertDoc(head, p); break; case 2: printf("修改信息"); scanf("%s", name); if ((p=FindDoc(head,name)) !=NULL) { printf("录入信息:\n"); printf("姓名:"); scanf("%s",p->name); } else printf("no\n"); break; case 3: printf("删除信息;\n"); scanf("%s",name); if ((p=FindDoc(head,name)) !=NULL) head = DeleteDoc(head, name); else printf("no\n"); break; case 4 : printf ("查找姓名\n"); scanf("%s",name); if ((p=FindDoc(head,name)) !=NULL) { printf("姓名:%s\n",p->name); } else printf("no\n"); break; case 5: Print_Stu_Doc(head); break; case 6: break; } while(choice != 6); return 0; } struct stud_node * InsertDoc(struct stud_node * head, struct stud_node *stud) { struct stud_node *ptr; ptr = stud; if(head == NULL) { head = ptr; head->next = NULL; } else { ptr->next=head; head=ptr; } return head; } struct stud_node * DeleteDoc(struct stud_node * head, char *name) { struct stud_node *ptrl, *ptr2; while(head!=NULL && strcmp(head->name,name) == 0) {ptr2 = head; head = head->next; free(ptr2); } if(head == NULL) return NULL; ptrl = head; ptr2 = head->next; while(ptr2!=NULL){ if(strcmp(ptr2->name,name) == 0) { ptrl->next = ptr2->next; free(ptr2);} else ptrl = ptr2; ptr2 = ptrl->next; } return head; } int Print_Stu_Doc(struct stud_node * head) { struct stud_node * p; if(head == NULL){ printf("\nno\n"); } printf("记录:\n"); p = head; while ( p!=NULL) { printf("姓名:%s\n",p->name); } } struct stud_node * FindDoc(struct stud_node * head,char *name) { struct stud_node * p=head; while(p!=NULL) { if(strcmp(p->name,name)==0) return p; else p=p->next; } return p; }这样之后按什么都无效
萌新求教 书里的程序 写出运行结果 我运行 结果报错 #include <iostream> using namespace std; int n; int *p1; int fun(){ static int a; int b; cout<<"a="<<a<<","; cout<<"b="<<b<<endl; } void main(){ int *p2; int m; fun(){ int n(10),m(20); cout<<"n="<<n<<endl<<"m="<<m<<endl; } cout<<"n="<<n<<endl<<"m="<<m<<endl; if(p1) cout<<"p1="<<p1<<endl; if(p2) cout<<"p2="<<p2<<endl; } #include <iostream.h> double f(int a=10,int b=20,int c=5){ return a*b*c; } void main(){ cout<<f()<<endl<<f(20)<<endl<<f(10,10)<<endl<<f(10,10,10)<<endl; } #include <iostream> #include <memory> using namespace std; struct node{ int data; shared_ptr<node>next; }; void main(){ int a[]={3,4,1,8,9,2,7}; shared_ptr<node>list(new node),p; list->data=0; for(auto v:a){ shared_ptr<node>q(new node) q->data = v; p->next = q; p = p-> next; } p->next=null; p=list->next; int s=0; while(p){ cout<<p->data<<"\n"; s+=p->data; p=p->next; } cout<<"\ns="<<s<<endl; }
售w9pve剑纯一个 有一套200成衣 外观号 只售200 售w9pve剑纯一个 有一套200成衣 外观号 只售200 卖个成本价 有意5985qq62464
1
下一页