poj 1577 Falling Leaves
来源:互联网 发布:设计app软件多少钱 编辑:程序博客网 时间:2024/06/04 18:06
非常简单,输入字符串到一个一维数组,然后从字符串的末尾往前
#include <iostream>#include <cstdio>#include <fstream>#include <cstring>#include <string.h>#include <stack>using namespace std;struct nodeT{ char value; nodeT *left,*right;};nodeT *makeNode(){ nodeT *new_node = new nodeT; new_node->left = NULL; new_node->right= NULL; return new_node;}void find_null(nodeT *root,char s){ if(s<root->value){ if(root->left==NULL) { root->left = makeNode(); root->left->value =s; return; } else{ find_null(root->left,s); } } else{ if(root->right==NULL) { root->right = makeNode(); root->right->value =s; return; } else{ find_null(root->right,s); } }}void front(nodeT *root){ cout<<root->value; if(root->left){front(root->left);} if(root->right){front(root->right);}}void function(char senten[5000]){ int posi = strlen(senten) -1; nodeT *root = makeNode(); root->value = senten[posi]; for(int i=posi-1;i>=0;i--){ find_null( root,senten[i]); } front(root); cout<<endl;}int main(){ //ifstream cin("ha.txt"); int posi=0; char senten[5000],line[100]; while(cin>>line) { if(line[0]!='*'&&line[0]!='$') { strcpy(senten+posi,line); posi+=strlen(line); } else { posi=0; //cout<<senten<<endl; function(senten); if(line[0]=='$'){return 0;} } }}
0 0
- POJ-1577-Falling Leaves
- POJ 1577 Falling Leaves
- POJ 1577 Falling Leaves
- poj 1577 Falling Leaves
- POJ 1577 Falling Leaves
- poj 1577 Falling Leaves
- zoj 1700 || poj 1577 Falling Leaves(BST)
- poj 1577 Falling Leaves
- 二叉树 Poj 1577 Falling Leaves
- POJ 1577 Falling Leaves 二叉树题解
- poj-1577 Falling Leaves(搜索二叉树)
- POJ 1577 Falling Leaves 二叉树操作
- POJ 1577 Falling Leaves 二叉树
- poj 1577 Falling Leaves(二叉搜索树)
- PKU 1577 Falling Leaves
- zoj 1700 || poj 1577 Falling Leaves(BST应用)
- POJ 1577 Falling Leaves(二叉搜索树)
- POJ 1577 Falling leaves (二叉树的构造)
- Zookeeper总结
- NSUserDefaults API中英文文档简介及使用
- [Python]核心编程之GUI编程(其他GUI初探)
- 关于delphi调用vc编写的dll中参数类型有关问题
- Eygle的《深入解析Oracle-DBA 入门、进阶与诊断案例》——脚本整理
- poj 1577 Falling Leaves
- c++强制转换
- Delphi调用VC动态库的Char指针返回有关问题
- HDU 4891 The Great Pan 解题报告(水题)
- (笔记)数据仓库工具箱:维度建模的完全指南--总线结构
- Struct2
- Unix/Linux环境C编程入门教程(41) C语言库函数的文件操作详解
- 腾讯前端题面试题(一)及答案
- Longest Palindrome - UVa 11151 dp