#include<stdlib.h>
#include<string.h>
#include<math.h>
#define MAX 100
typedef struct student{
char name[10]
double height
double weight
double scholar
}student
student a[MAX]
void input(student a[], int n)
void output(const student a[], int n)
void sort(student a[], int n)
void input(student a[], int n){
int i=0
for(i=0i<ni++){
printf("请输入学生姓名:")
scanf("%s",a[i].name)
printf("请输入学生身高:")
scanf("%lf",&a[i].height)
printf("请输入学生体重:")
scanf("%lf",&a[i].weight)
printf("请输入学生奖学金:")
scanf("%lf",&a[i].scholar)
}
}
void output(const student a[], int n){
int i=0
printf("学生信息为:\n")
for(i=0i<ni++){
printf("姓名:%s\t身高:%.2f\t体重:%.2f\t奖学金:%.2f\n",a[i].name,a[i].height,a[i].weight,a[i].scholar)
}
}
void sort(student a[], int n){
student t
int i=0,j=0
for(i=0i<n-1i++){
for(j=0j<n-i-1j++){
if(a[j].weight>a[j+1].weight){
t=a[j]
a[j]=a[j+1]
a[j+1]=t
}
}
}
printf("按体重排序后:\n")
output(a,n)
}
int main(){
int n=0
printf("请输入学生个数:")
scanf("%d",&n)
input(a,n)
output(a,n)
sort(a,n)
return 0
}
var s = prompt("请输入性别:(男或女)", "")var h = prompt("请输入身高:(厘米)", "") * 1
var t = prompt("请输入体重:(公斤)", "") * 1
if (s == "男") {
if (t >= h - 100 - 3 &&t <= h - 100 + 3) {
alert("男士体重符合标准")
} else {
alert("男士体重不符合标准")
}
} else if (s == "女") {
if (t >= h - 110 - 3 &&t <= h - 110 + 3) {
alert("女士体重符合标准")
} else {
alert("女士体重不符合标准")
}
}
#include <stdio.h>#include <stdlib.h>
void SelectionSort(float *a, int n)
{
int i,j
int min
float t
for(i = 0i <n-1i ++)
{
min = i
for(j = i+1j <nj ++)
if(a[min] >a[j])
{
min = j
}
t = a[min]
a[min] = a[i]
a[i] = t
}
}
int main()
{
float a[100]
int n
int i
scanf("%d",&n)
for(i = 0i <ni++)
scanf("%f",&a[i])
SelectionSort(a, n)
for(i = 0i <ni ++)
printf("%.2f\n",a[i])
}