zoukankan      html  css  js  c++  java
  • 每日一九度之 题目1069:查找学生信息

    时间限制:1 秒

    内存限制:32 兆

    特殊判题:

    提交:14402

    解决:3913

    题目描述:

     输入N个学生的信息,然后进行查询。

    输入:

     输入的第一行为N,即学生的个数(N<=1000)

    接下来的N行包括N个学生的信息,信息格式如下:
    01 李江 男 21
    02 刘唐 男 23
    03 张军 男 19
    04 王娜 女 19
    然后输入一个M(M<=10000),接下来会有M行,代表M次查询,每行输入一个学号,格式如下:
    02
    03
    01
    04
    输出:

     输出M行,每行包括一个对应于查询的学生的信息。

    如果没有对应的学生信息,则输出“No Answer!”
    样例输入:
    4
    01 李江 男 21
    02 刘唐 男 23
    03 张军 男 19
    04 王娜 女 19
    5
    02
    03
    01
    04
    03
    样例输出:
    02 刘唐 男 23
    03 张军 男 19
    01 李江 男 21
    04 王娜 女 19
    03 张军 男 19

    因为本题数据小,所以可以用桶排的方法解决。

    //Asimple
    #include <iostream>
    #include <algorithm>
    #include <cstring>
    #include <cstdio>
    #include <vector>
    #include <cctype>
    #include <cstdlib>
    #include <stack>
    #include <cmath>
    #include <set>
    #include <map>
    #include <string>
    #include <queue>
    #include <limits.h>
    #define INF 0x7fffffff
    using namespace std;
    const int maxn = 105;
    typedef long long ll;
    int n, sum;
    typedef struct node{
        bool f;
        char name[maxn];
        char sex[10];
        int age;
    }Stu;
    Stu stu[1005];
    
    int main(){
        while( ~scanf("%d",&n) ){
            for(int i=0; i<1005; i++){
                stu[i].f = false;
            }
            char a[maxn], b[maxn];
            int num, m;
            for(int i=0; i<n; i++){
                scanf("%d %s %s %d",&num,a,b,&m);
                stu[num].f = true;
                strcpy(stu[num].name, a);
                strcpy(stu[num].sex, b);
                stu[num].age = m; 
            }
            scanf("%d",&m);
            while( m -- ){
                scanf("%d",&num);
                if( stu[num].f ){
                    if( num < 10 ) printf("0");
                    printf("%d %s %s %d
    ",num,stu[num].name,stu[num].sex,stu[num].age);
                } else {
                    printf("No Answer!
    ");
                }
            }
        }
        return 0;
    }
    低调做人,高调做事。
  • 相关阅读:
    ubuntu下文件安装与卸载
    webkit中的JavaScriptCore部分
    ubuntu 显示文件夹中的隐藏文件
    C语言中的fscanf函数
    test
    Use SandCastle to generate help document automatically.
    XElement Getting OuterXML and InnerXML
    XUACompatible meta 用法
    Adobe Dreamweaver CS5.5 中文版 下载 注册码
    The Difference Between jQuery’s .bind(), .live(), and .delegate()
  • 原文地址:https://www.cnblogs.com/Asimple/p/5927950.html
Copyright © 2011-2022 走看看