#23993: 為啥不行呀?

#### 48992555 (孤峰)

School : 南光高中
ID : 123056
2021-05-05 18:17:32
f312. 1. 人力分配 -- | From: [210.71.26.21] | Post Date : 2021-01-08 14:50

#include <stdio.h>

#include <stdlib.h>

int main(int argc, char *argv[]) {

int a1,a2,b1,b2,c1,c2,n;

scanf("%d %d %d",&a1,&b1,&c1);

scanf("%d %d %d",&a2,&b2,&c2);

scanf("%d",&n);

int x1,x2,y1,y2;

int a[x1];

int b[x1];

int c;

for(x1=0;x1<=n;x1++){

x2=n-x1;

y1=a1*x1*x1+b1*x1+c1;

y2=a2*x2*x2+b2*x2+c2;

a[x1]=y1;

a[x1+1]=y2;

b[x1]=y1+y2;

}

for(x1=0;x1<n;x1++){

for(x1=0;x1<n;x1++)

if(b[x1]>b[x1+1]){

int d=b[x1];

b[x1]=b[x1+1];

b[x1+1]=d;

}

}

x1=n;

printf("%d ", b[x1]);

return 0;

}

#25679: Re:為啥不行呀?

#### kaihsinchen (Kai-Hsin Chen)

School : 國立高雄師範大學附屬高級中學
ID : 56928
2021-06-11 16:17:30
f312. 1. 人力分配 -- | From: [36.239.142.4] | Post Date : 2021-06-11 16:27

#include

#include

int main(int argc, char *argv[]) {

int a1,a2,b1,b2,c1,c2,n;

scanf("%d %d %d",&a1,&b1,&c1);

scanf("%d %d %d",&a2,&b2,&c2);

scanf("%d",&n);

int x1,x2,y1,y2;

int a[x1];

int b[x1];

int c;

for(x1=0;x1<=n;x1++){

x2=n-x1;

y1=a1*x1*x1+b1*x1+c1;

y2=a2*x2*x2+b2*x2+c2;

a[x1]=y1;

a[x1+1]=y2;

b[x1]=y1+y2;

}

for(x1=0;x1<n;x1++){

for(x1=0;x1<n;x1++)

if(b[x1]>b[x1+1]){

int d=b[x1];

b[x1]=b[x1+1];

b[x1+1]=d;

}

}

x1=n;

printf("%d ", b[x1]);

return 0;

}

ZeroJudge Forum