题目:
本题要求编写程序,按照规定格式输出表格。
输入格式:
本题目没有输入。
输出格式:
要求严格按照给出的格式输出下列表格:
------------------------------------ Province Area(km2) Pop.(10K) ------------------------------------ Anhui 139600.00 6461.00 Beijing 16410.54 1180.70 Chongqing 82400.00 3144.23 Shanghai 6340.50 1360.26 Zhejiang 101800.00 4894.00
------------------------------------
实现代码:
#include <stdio.h> #include <string.h> #include <stdlib.h> void Print_Lines(); void Print_String(char string[]); int main() { int index=0; int i=0; char buffer[18][20]={"Province ","Area(km2) ","Pop.(10k) \n", "Anhui ","139600.00 ","6461.00 \n", "Beijing ","16410.54 ","1180.70 \n", "Chongqing ","82400.00 ","3144.23 \n", "Shanghai ","6340.50 ","1360.26 \n", "Zhejing ","101800.00 ","4894.00 \n"}; Print_Lines(); for(i=0;i<3;i++) { Print_String(buffer[index++]); } Print_Lines(); for(i=0;i<15;i++) { Print_String(buffer[index++]); } Print_Lines(); system("pause"); } void Print_Lines() { int i=0; for(i=0; i<36;i++) { printf("%s","-"); } printf("\n"); } void Print_String(char string[]) { printf("%s",string); }
PAT - IO-01. 表格输出(5),布布扣,bubuko.com
原文:http://www.cnblogs.com/haihai1203/p/3860998.html