跳到正文

个人记录

数学建模

paperghost_ls约 2 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2026年8月11日
篇幅
约 2 分钟

版本

  1. v2当前
  2. v1

高二数学建模比赛所用程序如下,保存以作纪念

C++
#include<cstdio>
using namespace std;
int n;
struct node
{
    int bj;
    double fs;
}a[1000001];int num;
void exchange(node a,node b)
{
    double t=a.fs;
    a.fs=b.fs;
    b.fs=t;
    return;
}
void qsort(int l,int r)
{
    double mid=a[(l+r)/2].fs;
    int i=l,j=r;
    do{
        while(a[i].fs<mid) i++;
        while(a[j].fs>mid) j--;
        if(i<=j)
        {
            exchange(a[i],a[j]);
            i++;
            j--;
        }
    }while(i<=j);
    if(l<j) qsort(l,j);
    if(i<r) qsort(i,r);
}
double an[4]={0,17.0,18.0,19.0},bn[4]={0,48.0,50.0,52.0},cn[4]={0,81.0,82.0,83.0},dn[4]={0,97.5,98.0,98.5};
int ia,ib,ic,id;
int main()
{
    int city;scanf("%d",&city);
    num=0;
    while(city)
    {
        int n;scanf("%d",&n);num+=n;
        for(int i=num-n+1;i<=num;i++)
        {
            scanf("%lf",&a[i].fs);
            a[i].bj=city;
        }
        city--;
    }
    qsort(1,num);
    for(int i=1;i<=num;i++)
    {

    }
    return 0;
}
原文