Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Help to change the program, there is an error and it can't run. Thank you very much. . . Urgent.
Help to change the program, there is an error and it can't run. Thank you very much. . . Urgent.
# include & ltstdio.h & gt

# include & ltstdlib.h & gt

# include & ltstring.h & gt

# Definition number 10

Structural city

{

char CN[ 100]; //City name

Int SH// Total number of housing units in the city

Int SP// Total number of households in the city

Double AvgP// Number of houses per household

} ten _ city[N];

void paixu()

{

int t_SH,t_SP,j=0,I;

Double t _ AvgP

char t _ CN[ 100];

while(j & lt; n)

{

for(I = j+ 1; I & ltn;; i++)

{

If (ten _ cities [j]. AvgP & gt Ten cities. AvgP)

{

t_SH = ten_city[i]。 SH;

t_SP = ten_city[i]。 SP;

t_AvgP = ten_city[i]。 AvgP

strcpy(t_CN,ten_city[i])。 CN);

Ten cities. SH = ten_city[j]。 SH;

Ten cities. SP = ten_city[j]。 SP;

Ten cities. AvgP = ten_city[j]。 AvgP

strcpy(ten_city[i].CN,ten_city[j]。 CN);

X _ city [j]. SH = t _ SH

X _ city [j]. SP = t _ SP

X _ city [j]. AvgP = t _ AvgP

strcpy(ten_city[j].CN,t _ CN);

}

}

printf("\n%s\t%d\t%d\t%f ",ten_city[j]。 CN,ten_city[j]。 SH,ten_city[j]。 SP,ten_city[j]。 AvgP);

j++;

}

}

void main()

{

int I;

Printf ("\ nName: # #, Student ID: # #, Class: # # #");

for(I = 0; I & ltn;; i++)

{

Printf ("\ nPlease enter the city name %d:", i+1);

Get (ten_city[i]. CN);

Printf ("\ nPlease enter the total number of housing units in city %d:", i+1);

Scanf("%d ",&Ten cities. SH);

Printf ("Please enter the total number of households in city %d:", I+1);

Scanf("%d ",&Ten cities. SP);

getchar(); //Clear the carriage return entered by scanf.

Ten cities. AvgP = (double)ten_city[i]。 SH/(double)ten_city[i]。 SP;

}

Printf ("\ nRanked according to the number of houses from low to high: \ nCity order \ tTotal number of houses \ tTotal number of families \ tAverage number of houses \ n");

Paixu ();

printf(" \ n \ n ");

}

The above procedures can be run directly!

I hope it helps you.