经典童话剧背景音乐<<饼干小子>>在我市青少年宫影剧院欢乐进行

1.课件:表达式的三种表示形式及其规律
2.后缀表达式求值以及如何实现
Knuth 将此概括为三个步骤:
?  对中缀表达式进行语法分析
?  中缀表达式到后缀表达式的转换
?  对后缀表达式求值
C语言建议代码是实现:
3.我的Java语言实现,利用了Java自身的优越性,可以更好的处理一些内容 (做这个是为了完成数据结构的课程设计,后期会有相应的文章介绍我的作品《算术24游戏》,谢谢关注)
//测试的main方法
public static void main(String arg[]) {
String s = &2+6*7-5/1*7&;
ArrayList postfix = transform(s);
for (int i = 0, len = postfix.size(); i & i++) {
System.out.println(postfix.get(i));
calculate(postfix);
//将中缀表达式转换成后缀表达式
public static ArrayList transform(String prefix) {
System.out.println(&transform&);
int i, len = prefix.length();// 用字符数组保存前缀表达式
prefix=prefix+ '#';// 让前缀表达式以'#'结尾
Stack&Character& stack = new Stack&Character&();// 保存操作符的栈
stack.push('#');// 首先让'#'入栈
ArrayList postfix = new ArrayList();
// 保存后缀表达式的列表,可能是数字,也可能是操作符,之前使用的是ArrayList
for (i = 0; i & len + 1; i++) {
System.out.println(i+& &+prefix.charAt(i));
if (Character.isDigit(prefix.charAt(i))) {// 当前字符是一个数字
if (Character.isDigit(prefix.charAt(i+1))) {// 当前字符的下一个字符也是数字(两位数)
postfix.add(10 * (prefix.charAt(i)-'0') + (prefix.charAt(i+1)-'0'));
} else {// 当前字符的下一个字符不是数字(一位数)
postfix.add((prefix.charAt(i)-'0'));
} else {// 当前字符是一个操作符
switch (prefix.charAt(i)) {
case '(':// 如果是开括号
stack.push(prefix.charAt(i));// 开括号只是放入到栈中,不放入到后缀表达式中
case ')':// 如果是闭括号
while (stack.peek() != '(') {
postfix.add(stack.pop());// 闭括号是不入栈的
stack.pop();// 弹出'('
default:// 默认情况下:+ - * /
while (stack.peek() != '#'
&& compare(stack.peek(), prefix.charAt(i))) {
postfix.add(stack.pop());// 不断弹栈,直到当前的操作符的优先级高于栈顶操作符
if (prefix.charAt(i) != '#') {// 如果当前的操作符不是'#'(结束符),那么入操作符栈
stack.push(prefix.charAt(i));// 最后的标识符'#'是不入栈的
//比较运算符之间的优先级
public static boolean compare(char peek, char cur) {// 如果是peek优先级高于cur,返回true,默认都是peek优先级要低
if (peek == '*'
&& (cur == '+' || cur == '-' || cur == '/' || cur == '*')) {// 如果cur是'(',那么cur的优先级高,如果是')',是在上面处理
return true;
} else if (peek == '/'
&& (cur == '+' || cur == '-' || cur == '*' || cur == '/')) {
return true;
} else if (peek == '+' && (cur == '+' || cur == '-')) {
return true;
} else if (peek == '-' && (cur == '+' || cur == '-')) {
return true;
} else if (cur == '#') {// 这个很特别,这里说明到了中缀表达式的结尾,那么就要弹出操作符栈中的所有操作符到后缀表达式中
return true;// 当cur为'#'时,cur的优先级算是最低的
return false;// 开括号是不用考虑的,它的优先级一定是最小的,cur一定是入栈
//计算后缀表达式
public static boolean calculate(ArrayList postfix){//后缀表达式的运算顺序就是操作符出现的先后顺序
System.out.println(&calculate&);
int i,res=0,size=postfix.size();
Stack&Integer& stack_num=new Stack&Integer&();
for(i=0;i&i++){
if(postfix.get(i).getClass()==Integer.class){//说明是操作数,这个很有用啊!
stack_num.push((Integer)postfix.get(i));
System.out.println(&push&+& &+(Integer)postfix.get(i));
}else{//如果是操作符
System.out.println((Character)postfix.get(i));
int a=stack_num.pop();
int b=stack_num.pop();//注意运算时的前者和后者
switch((Character)postfix.get(i)){
System.out.println(&+ &+a+& &+b);
System.out.println(&- &+a+& &+b);
System.out.println(&* &+a+& &+b);
System.out.println(&/ &+a+& &+b);
stack_num.push(res);
System.out.println(&push&+& &+res);
res=stack_num.pop();
System.out.println(&res &+& &+res);
if(res==24){
return true;
return false;
}程序中的很多的输出是为了让我们更加清楚地看到整个的执行过程:想知道的话可以看看输出结果transform
res  9中缀表达式为 2+6*7-5/1*7 ,最终的结果是 9中缀表达式为 (2+6)*7-5/1*7 ,最终的结果是 21 注:你可能觉得整个代码的结构不是很好,这个因为这个程序不是单纯的用于计算中缀表达式的,它是我做的《算术24游戏》的其中的一个模块,后期将会呈现,敬请期待英语童话剧三只小猪&Three little pigs&_幼儿园英语教案
幼儿教育网,正确认识幼儿教育以及科学对待幼儿教育,让孩子健康快乐地成长。
英语童话剧三只小猪&Three little pigs&
小白猪:Little white 小黑猪:little black 小花猪little white and black
1、(三只小猪边唱着歌边出场)Who&s afraid of the big bag wolf , big bag wolf , big bag wolf .
Who&s afraid of the big bag wolf , big bag wolf , big bag wolf .
La la la la la .
2、(小鸟边唱歌边出场)Fly little birdie fly.
Fly little birdie fly.
Up to the sky , la la la la la la la la la la la la .
Happy cause I&m free.
小白猪:Good morning, bird.
小鸟:Good morning, little white. Can I help you ?
小白猪:Yes. Please give me some straw. I want to make a house.
小鸟:ok , here you are.
3、大象出场:I&m elephent , I&m stong.
Good morning, elephent.
Good morning, little black. Can I help you ?
小黑猪:Yes. Please give me some sticks. I want to make a house.
大象:Ok . here you are.
小黑猪:Thank you.
4、小猫、小猴、小鸡、小羊出场,抱着石头边唱边跳
小花猪:Hello . I&m little white and black. I want to make a house.
friends , come here.
小猫、小猴、小鸡、小羊:Ok. Let&s help you.大家一起帮小花猪边盖房子边唱歌: 1
上一篇: 下一篇:
看过《英语童话剧三只小猪&Three little pigs&》的同学还看了:
· · · · · · · · · · · ·
· · · · · · · · · ·
· · · · · · · · · ·子曰经典<相对>MV_土豆_高清视频在线观看免费在线观看 歌曲&&滚滚长江东逝...
方式一:扫一扫
支持各类二维码扫描软件
方式二:发一发
免费发送App到手机
看不清验证码不正确
该短信不收取任何费用
方式三:下一下
下载App观看
还有更多攻略和游戏礼包等着你
嵌入代码:
这个支持手机播放哦
专区热点·
大家都在看
手机看视频
阿喜&宠辱不惊
月大美人~`
香奈*平平淡淡
douyuxiaozhi
White55开解说

我要回帖

更多关于 童话剧剧本 的文章

 

随机推荐