[ create a new paste ] login | about

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

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


Output:
1
2
3
4
In function 'main':
Line 16: error: 'for' loop initial declaration used outside C99 mode
Line 17: error: 'for' loop initial declaration used outside C99 mode
Line 25: error: 'for' loop initial declaration used outside C99 mode


Create a new paste based on this one


Comments: