Description
现在有不定个数(小于100)的三维点的坐标(x,y,z),都是浮点数据,并且不同点的z坐标都不相同。要求按照z的值从小到大输出这些点的三维坐标。
Input
多行,每行三个浮点数,中间用空格分隔。
Output
多行,每行三个浮点数,中间用英文逗号分隔。参见样例。
Sample Input
1.0 1.1 1.2
2.1 2.02 1.0
3.0 2.5 1.5
Sample Output
2.1,2.02,1.0
1.0,1.1,1.2
3.0,2.5,1.5
//三维点坐标排序(要求用指针)
#include<bits/stdc++.h>
using namespace std;
const int MAXN=105;
int maxn[MAXN];
int a[MAXN];
struct note
{
double x,y,z;
} ;
int swap(double *a,double *b)
{
double t=*a;
*a=*b;
*b=t;
}
int main()
{
struct note a[MAXN];
int x,y,z;
int n=0;
while(cin>>a[n].x>>a[n].y>>a[n].z)
{
n++;
}
for(int i=0; i<n-1; i++)
{
for(int j=0; j<n-i-1; j++)
{
if(a[j+1].z<a[j].z)