//有 10 个职工,每个职工的数据包括:编号、姓名、基本工资,输入这 10 个职工的信息, 然后求出其中“基本工资”最少的职工姓名。(请给出结构体定义)
#include <stdio.h>
struct Pro {
int num;
char name[10];
float salary;
};
int main() {
struct Pro pro[10];
int min = 65535;
int num = 0;
for (int i = 0; i < 10; i++) {
printf("请输入编号、姓名、基本工资\n");
scanf("%d %s %f", &(pro[i].num), pro[i].name, &(pro[i].salary));
}
for (int i = 0; i < 10; i++) {
if (pro[i].salary<min) {
num = i;
min = pro[i].salary;
}
}
printf("%s的工资最少", pro[num].name);
}
char *leastSalary(struct staff *staffs, int n) {
int min_index = 0;
for (int i = 0; i < n; ++i) {
if (staffs[i].salary < staffs[min_index].salary)
min_index = i;
}
return staffs[min_index].name;
}
int main(void)
{
struct staff staffs[10];
for (int i = 0; i < 10; ++i) {
printf("Input the NO.%d information of 10 staffs(number, name, salary): ", i + 1);
scanf("%d%s%f", &staffs[i].number, &staffs[i].name, &staffs[i].salary);
}
printf("The least salary owner is %s!\n", leastSalary(staffs, 10));
return 0;
}
#include<stdio.h>
struct stu{//结构体构建包含职工信息的节点
int ID;
char name[10];
float salary;
}s[4];//节点集合
int main(){
int i,min=0;
for(i=0;i<3;i++){
printf("please enter information NO.%d:\n",i+1);
scanf("%d%s%f",&s[i].ID,s[i].name,&s[i].salary);
}
for(i=0;i<3;i++){
if(s[min].salary>s[i].salary){
min=i;
}
}
printf("min is %s",s[min].name);
return 0;
}
#include <stdio.h>
#define N 10
struct Employee{
int eno;
char ename[10];
double esalary;
}employee[N];
int main(){
int i,j,salmin=0;
for(i=0;i<N;i++){
printf("%d\n",i+1);
printf("employee number:");
scanf("%d",&employee[i].eno);
printf("employee name:");
scanf("%s",&employee[i].ename);
printf("employee salary:");
scanf("%f",&employee[i].esalary);
printf("\n");
}
for(j=1;j<N;j++){
if(employee[j].esalary<employee[salmin].esalary){
salmin=j;
}
}
printf("the name of employee whose salary is minimum is %s",employee[salmin].ename);
return 0;
}
struct employee{
int num;
char name[10];
float salary;
}a[10];
int main(){
int n = 10;
int i;
for(i = 0; i < 10; ++i)
scanf("%d%s%f",a[i].num, a[i].name, a[i].salary);
int k = 0;
for(i = 1; i < 10; ++i){
if(a[k].salary > a[i].salary)
k = i;
}
printf("%s", a[k].name);
return 0;
}
#include <stdio.h>
struct student
{
int num;
char name[8];
float salary;
} s[3];
int main()
{
int min, i;
for (i = 0; i < 3; i++)
scanf ("%d%s%f", &s[i].num, s[i].name, &s[i].salary);
min = 0;
for (i = 1; i < 3; i++)
if (s[min].salary > s[i].salary)
min = i;
printf("%s\n", s[min].name);
return 0;
}
#include
struct worker{
int bianhao;
char name[10];
int gongzi;
}wor[10];
int main()
{
int i;
for(i=0;i<10;i++)
scanf("%d%s%d",&wor[i].bianhao,wor[i].name,&wor[i].gongzi);
int j=0,k=0,min;
min=wor[j].gongzi;
for(j=1;j<10;j++){
if(wor[j].gongzi
登录后提交答案