poj 百练2799(基础题)
2012-05-16 10:00
246 查看
对于浮点数进行“对齐”
当成字符串来处理
当成字符串来处理
#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 ; }
相关文章推荐
- poj 3481 slpay 基础题
- poj 1258 Agri-Net(Prim)(基础)
- poj 基础入门题
- 原poj 2680(基础题)
- POJ 2485 Highways(最小生成树,基础模板题)
- poj 3304 Segments(计算几何基础)
- poj 百练 2976(基础题)
- POJ 2251 基础搜索 BFS 五
- POJ 算法基础 编程题#1:集合加法
- poj Wireless Network(基础并查集)
- POJ1010-搜索题基础
- POJ 3468 线段树 区间修改 基础题
- POJ 1201 Intervals(差分约束基础)
- poj1222高斯消元基础题
- poj 3070 Fibonacci 矩阵基础题
- POJ 2104 划分树学习基础题
- poj 3278 catch that cow BFS(基础水)
- poj 2342 Anniversary party(树形DP基础题)(树形dp模板)
- POJ 1654 几何基础
- POJ1195——二维BIT基础