SDUT3116->图的基本存储的基本方式一

#include<bits/stdc++.h>
bool g[5000][5000];
int main()
{
    int n, m, u, v;
    while(~scanf("%d%d", &n, &m))
    {
        memset(g,0,sizeof(g));
        for(int i=0; i<m; i++)
        {
            scanf("%d%d", &u, &v);
            g[u][v]=1;
        }
        int q;
        scanf("%d", &q);
        while(q--)
        {
            int a, b;
            scanf("%d%d", &a, &b);
            if(g[a][b])
            {
                printf("Yes\n");
            }
            else
            {
                printf("No\n");
            }
        }
    }
    return 0;
}



/***************************************************
User name: ACM18171信科1801张林
Result: Accepted
Take time: 1300ms
Take Memory: 2164KB
Submit time: 2019-01-01 17:39:45
****************************************************/

 

这是一个简单的学生集合的示例代码,您可以参考: ```c++ #include <iostream> #include <string> #include <vector> using namespace std; class Student { private: string name; int age; double score; public: Student(string n, int a, double s) : name(n), age(a), score(s) {} string getName() const { return name; } int getAge() const { return age; } double getScore() const { return score; } }; class StudentCollection { private: vector<Student> students; public: void addStudent(Student s) { students.push_back(s); } void removeStudent(Student s) { for (vector<Student>::iterator it = students.begin(); it != students.end(); ++it) { if (it->getName() == s.getName()) { students.erase(it); break; } } } void printStudents() const { for (vector<Student>::const_iterator it = students.begin(); it != students.end(); ++it) { cout << "Name: " << it->getName() << ", Age: " << it->getAge() << ", Score: " << it->getScore() << endl; } } }; int main() { StudentCollection sc; sc.addStudent(Student("Tom", 18, 90)); sc.addStudent(Student("Jerry", 20, 80)); sc.addStudent(Student("Alice", 19, 85)); sc.printStudents(); sc.removeStudent(Student("Jerry", 20, 80)); sc.printStudents(); return 0; } ``` 这个示例代码中,定义了一个 `Student` 类和一个 `StudentCollection` 类。其中 `Student` 类表示一个学生,包括学生姓名、年龄、分数等信息。`StudentCollection` 类表示一个学生集合,包括添加学生、删除学生、打印学生信息等操作。在 `main` 函数中,演示了如何使用 `StudentCollection` 类来管理学生集合。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值