POJ 1896 Code Formatting
来源:互联网 发布:网络教育学费多少 编辑:程序博客网 时间:2024/05/22 02:03
题意:
给一份代码,让它的格式标准化。
思路:
模拟。
code:
#include <iostream>#include <cstring>#include <cstdio>using namespace std;string data;int level = 1, len;bool flag;int main(){while (getchar() != '{') ;printf("{\n ");flag = false;while (getline(cin, data)){len = data.length();for (int i = 0; i < len; ++ i){if (data[i] == ' ' || data[i] == 9) ;else if (data[i] == '{'){printf(" {\n");level ++;for (int j = 0; j < level; ++ j)printf(" ");}else if (data[i] == ';'){printf(";\n");flag = true;}else if (data[i] == '}'){level --;for (int i = 0; i < level; ++ i)printf(" ");putchar('}');flag = false;}else if (data[i] == ',') printf(", ");else{if (flag){for (int i = 0; i < level; ++ i)printf(" ");flag = false;}putchar(data[i]);}}if (level == 0) break;}printf("\n");}
- POJ 1896 Code Formatting
- poj 1093 Formatting Text
- poj 1093 Formatting Text
- Poj 3428 Formatting function
- poj 1093 Formatting Text (DP)
- POJ 1093 Formatting Text(DP)
- POJ 3428 Formatting function 可能会
- POJ 1093 Formatting Text 笔记
- Swift编程规范之 Code Formatting
- Formatting
- POJ 3428 Formatting function (文件输入)
- Formatting Text - UVa 709 POJ 1093 dp
- poj - 1093 - Formatting Text(dp)
- Leet Code OJ 482. License Key Formatting [Difficulty: Medium]
- Code POJ
- Code POJ
- poj 1850 Code
- poj 1850 Code
- VS2010中的调试技巧
- <welcome-file-list>404
- POJ 1894 Alternative Scale of Notation
- C++ dlopen mini HOWTO 中译版
- hdu1789
- POJ 1896 Code Formatting
- WCF数据库开发一般分下面几步:
- Ant + ivy的安装
- 收藏的网址
- Openwrt python,openwrt上使用Python
- POJ 1899 Farmer Bill's Problem
- 程序员的十层楼
- 沟通技巧(节选自微软IE推广)
- Java异常处理