C的数据结构职工或者学生信息求指导
#include "stdafx.h"#include <stdio.h>
#include <string.h>
#include "file2.h"
int A;
int main()
{
student stu[4]={{10101,"利爱明",'M',18},{10102,"罗颖诗",'M',19},{10104,"李东芬",'M',19}
,{10105,"张莹",'F',18}};
OutputStudent(stu);
int b=3,c,d,m;
printf("enter the number a and its power m:\n");
scanf("%d,%d",&A,&m);
c=A*b;
printf("%d*%d=%d\n",A,b,c);
d=power(m);
printf("%d**%d=%d\n",A,m,d);
return 0;
}
file2.h
struct student{
long int num;
char name[20];
char sex;
int age;
};
int power(int);
void OutputStudent(student *);
file2.cpp
extern int A;
int power(int n)
{
int i,y=1;
for(i=1;i<=n;i++)
y*=A;
return(y);
}
void OutputStudent(student *p)
{
printf("No. Name Sex age\n");
for(int i=0;i<4;i++)
{
printf("%5d %-20s %2c %4d\n",p[i].num,p[i].name,p[i].sex,p[i].age);
}
}大概就像上面的程序那样。。。不过现在要设置一个员工的信息可以保存,搜索我想问问我应该怎么设置啊???