对于浮点数进行“对齐”
当成字符串来处理
#include <fstream>
#include <string.h>
#include <stdio.h>
#include <algorithm>
#define _cdebbug
using namespace std;
int main()
{
//重定向
#ifdef _cdebbug
freopen("F:\\input.txt","r",stdin );
#endif
char str[10001][51] ;
int floatpoint,i,j,n,k;
scanf("%d",&n);
memset(str,0,sizeof(char)*10001*51);
floatpoint = 0;
for (i = 0; i < n; ++i)
{
scanf("%s",str[i]);
for (j = 0; str[i][j] != '\0'; j++)
{
if (str[i][j] == '.')
break;
}
if (j > floatpoint)
floatpoint = j;
}
for (i = 0; i < n; ++i)
{
for (j = 0; str[i][j] != '\0'; j++)
if (str[i][j] == '.')
break;
for (k = 0; k < (floatpoint - j); ++k)
printf(" ");
printf( "%s\n" , str[i] );
}
//解除重定向关闭文件
#ifdef _cdebbug
fclose(stdin);
#endif
return 0 ;
}