删除职工哪里把要删除职工后面的全部前移1位,然后count--
不知道你这个问题是否已经解决, 如果还没有解决的话:代码如下(示例):
#include<iostream>
using namespace std;
void count(int x,int y);//函数声明
int main()
{
int a=3,b=4;
count(a,b);
cout<<"a="<<a<<'\t';
cout<<"y="<<b<<endl;
}
void count(int x,int y)
{
x=x*2;
y=y*y;
cout<<"x="<<x<<'\t';
cout<<"y="<<y<<endl;
}
我需要知道您具体使用的是哪种数据结构来储存职工信息,如果是使用文件来保存,则可以直接在文件中删除。如果是使用其他数据结构,则需要先找到需要删除的职工信息,然后删除该信息。
如果您是使用纯C++编写程序,则可以使用STL中的vector或map等容器来储存职工信息,并使用erase函数来删除指定职工信息。
以下是使用vector来储存职工信息并删除指定职工的示例代码:
#include <iostream>
#include <vector>
using namespace std;
struct Employee {
int id;
string name;
int age;
};
int main()
{
vector<Employee> employees = {
{1, "Max", 25},
{2, "Tom", 30},
{3, "John", 31},
{4, "Peter", 35}
};
// 删除id为2的职工
for (auto it = employees.begin(); it != employees.end(); ++it) {
if (it->id == 2) {
employees.erase(it);
break;
}
}
// 输出剩余职工信息
for (const auto& employee : employees) {
cout << employee.id << " " << employee.name << " " << employee.age << endl;
}
return 0;
}
如果您使用的是其他的库或框架,则可以查看其官方文档以获取具体的删除方法。