C语言 2道关于结构体的题 谢谢!悬赏放一起了

1.Description:
某企业有为员工祝贺生日的传统,但随着企业规模的扩大,员工人数的增多,该企业希望运用信息化技术,保存本企业所有员工的生日信息,查找指定日期过生日的员工,试编写一个程序,输入员工总数,员工的姓名、工号、出生日期以及待查询日期,根据员工的出生月、日,查找过生日的员工。若没找到,输出“Not Found”。

要求:

1、设该企业最多有员工100人,员工的信息包括姓名、工号、出生日期(年、月、日),要求使用结构体嵌套方式定义数据结构。

2、要求使用typedef对结构体进行重命名

3、要求划分合理函数完成。查找函数原型为:

void Input(Employee *p,int n); //n为员工总数,p为指向结构体数组的指针。

输出格式:

printf("%d月%d日过生日的有:\n",...... );

printf(" 姓名 工号 生日(年 月 日)\n");

printf("%8s%10d%14d%4d%4d\n",.......);

输入可以参考这样的代码。

scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%s %d %d %d %d",info[i].name,&info[i].no,&info[i].birthday.y,&info[i].birthday.m,&info[i].birthday.d);
}

Sample Input:
4
zhang 1001 1987 5 7
wang 1002 1998 5 7
sun 1003 1990 4 5
wanghi 1004 2000 10 10
5 7
Sample Output:
5月7日过生日的有:
姓名 工号 生日(年 月 日)
zhang 1001 1987 5 7
wang 1002 1998 5 7
Sample Input:
4
zhang 1001 1987 5 7
wang 1002 1998 5 7
sun 1003 1990 4 5
wanghi 1004 2000 10 10
5 8
Sample Output:
Not Found

2.Description:
建立一结构体,其中包括学生的姓名、性别、年龄和一门课程的成绩。建立的结构体数组通过输入存放全班(最多45人)学生信息,输入班级人数,以及每个学生的姓名,性别,年龄,成绩(以回车分隔),输出考分最高的学生的姓名、年龄、性别和课程的成绩。

提示:请使用getchar()读出多余的回车,不要使用fflush函数。fflush并不是C标准支持的函数,在一些编译器上不起作用。

输出格式:

printf("\nName\t\tSex\tAge\tScore\n");

printf("%s\t\t%c\t%d\t%5.1f\n",......);

Sample Input:
3
zhang san
m
18
89.9
li si
m
17
90.8
wang wu
f
18
99
Sample Output:
Name Sex Age Score
wang wu f 18 99.0

稍等,马上写给你。以后提问发5C悬赏就好。多了悬赏并不能得到更好的回答,反倒招惹垃圾来灌水。

图片说明

 // q677049_2.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

#include <stdio.h>
#include <stdlib.h>

typedef struct
{
char name[30];
char gender;
int age;
float score;
} Student;

int main(int argc, char* argv[])
{
    Student stu[45];
    int n;
    scanf("%d", &n);
    int max = 0;
    for (int i = 0; i < n; i++)
    {
        getchar();
        scanf("%[^\n]", stu[i].name);
        getchar();
        scanf("%c", &stu[i].gender);
        getchar();
        scanf("%d", &stu[i].age);
        getchar();
        scanf("%f", &stu[i].score);
        if (stu[max].score < stu[i].score) max = i;
    }
    printf("Name Sex Age Score\n");
    printf("%s %c %d %.1f\n", stu[max].name, stu[max].gender, stu[max].age, stu[max].score);
    return 0;
}

图片说明

 // q677049_1.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

#include <stdio.h>
#include <stdlib.h>
typedef struct
{
    int y;
    int m;
    int d;
} Date;

typedef struct
{
    char name[20];
    int no;
    Date birthday;
} Employee;

void Input(Employee *info, int *n)
{
    int i;
    scanf("%d", n);
    for(i = 0; i < (*n); i++)
    {
        scanf("%s %d %d %d %d", &(info[i].name), &info[i].no, &info[i].birthday.y, &info[i].birthday.m, &info[i].birthday.d);
    }
}

int main(int argc, char* argv[])
{
    Employee p[100];
    int m, d, i, n;
    Input(p, &n);
    scanf("%d %d", &m, &d);
    printf("%dÔÂ%dÈÕ¹ýÉúÈÕµÄÓУº\nÐÕÃû ¹¤ºÅ ÉúÈÕ£¨ÄêÔÂÈÕ£©\n", m, d);
    for (i = 0; i < n; i++)
    {
        if (p[i].birthday.m == m && p[i].birthday.d == d)
        {
            printf("%s %d %d %d %d\n", p[i].name, p[i].no, p[i].birthday.y, p[i].birthday.m, p[i].birthday.d);
        }
    }
    return 0;
}