[ create a new paste ] login | about

Link: http://codepad.org/ILdkjU8w    [ raw code | output | fork ]

C++, pasted on Oct 14:
#include<stdio.h>
#define STUDENTS 5
typedef struct{
int id;
double height;
double weight;
}Body;
int main(void)
{
int i,j;
body data[]={
{1,165,60},
{2,170,68},
{3,160,50},
{4,180,75},
{5,175,80},
},tmp;
for(i=0; i<STUDENTS-1;i++){
for(j=i+1; j<STUDENTS;j++){
if(data[i].height<data[j].height){
tmp=data[i];
data[i]=data[j];
data[j]=tmp;
}
}
}
for(i=0; i<STUDENTS; i++){
printf("id %d:%.1f, %.1f\n", data[i].id, data[i].height, data[i].weight);
return 0;
}


Output:
1
2
3
In function 'int main()':
Line 11: error: 'body' was not declared in this scope
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: