易截截图软件、单文件、免安装、纯绿色、仅160KB

数字表达式求值程序 (c/c++)

一个控制台下的数字表达式求值程序 (c/c++)
源代码见下:
#include <stdio.h>
#include <string>
#include <iostream>
#include <stdlib.h>
#include <vector>
#include <stack>
using namespace std;
//设置运算符优先级的算法
int Priority(const string opera) // 运算符优先级
{
    if(opera=="+"||opera=="-")
 {
  return (1);
 }
 else if(opera=="*"||opera=="/")
 {
  return (2);
 }
 else
 {
  return (0);
 }
}
void MiddlefixToPostfix(vector<string> &ivec1,vector<string> &ivec2)
//中缀表达式到后缀表达式的转换算法,ivec2中存放的是中缀表达式,将其转换为后缀表达式形式存放到ivec2中。
{
 //定义一个存放操作符的栈对象。
    stack<string> operatorstk; 
 
 for(vector<string>::size_type i=0;i!=ivec2.size();++i)
 {
        if(ivec2[i]=="(")
  {
   operatorstk.push(ivec2[i]);
  }
  else if(ivec2[i]=="+"||ivec2[i]=="-"||ivec2[i]=="*"||ivec2[i]=="/")
  {
   if(operatorstk.empty())
   {
    operatorstk.push(ivec2[i]);
   }
   else
   {
    if(Priority(ivec2[i])<=Priority(operatorstk.top()))
    {
        while( operatorstk.empty()==false && operatorstk.top()!="(" )
     {
                        ivec1.push_back(operatorstk.top());
      operatorstk.pop();
     }
     operatorstk.push(ivec2[i]);
    }
    else
    {


相关文档:

Linux I2C Input设备驱动代码的几点理解

最近在做一个I2C键盘的Linux驱动,参考了其他芯片的一些代码,其中陆续发现有些让人迷惑的东西,把我的迷惑及理解在这里加以记录:
1. i2c_driver结构体的probe成员的原型:
     int (*probe)(struct i2c_client *, const struct i2c_device_id *);
即:probe函数被调用时会从上边传两个个参 ......

C库函数(字符串函数)


C库函数
字符串函数
 
 
 
函数名
函数原型
功能
返回值
包含头文件
strcat
char *strcat(char *st1, char *str2)
把str2连接到str1后面
str1
string.h
strchr
char *strchr(char *str, int ch)
找出str指向的字符串中第一次出现字符串ch的位置
指向该位置的指针,未找到则返回空指针
......

C/C++ 宏带来的奇技淫巧

作者:Kevin Lynx 来源:C++博客
转自:http://www.kuqin.com/language/20080319/4797.html
众多C++书籍都忠告我们C语言宏是万恶之首,但事情总不如我们想象的那么坏,就如同goto一样。宏有
一个很大的作用,就是自动为我们产生代码。如果说模板可以为我们产生各种型别的代码(型别替换),
那么宏其实可以为我们在符号上 ......

C/C++编程必备

Windows C 程序设计入门与提高
http://download.chinaitlab.com/program/files/13246.html
单片机C语言入门
http://download.chinaitlab.com/program/files/12907.html
C++ 入门基础教程
http://download.chinaitlab.com/program/files/7617.html
C语言常用算法源代码
http://download.chinaitlab.com/program/files ......

Objective C 2.0 简明教程 (5) 属性(Property)


Objective C 2.0 简明教程 (5) 属性(Property)





作者:Administrator
  

周六, 2009年 03月 28日 07:47
Objective C 2.0 为我们提供了property。它大大简化了我们创建数据成员读写函数的过程,更为关键的是它提供了一种更为简洁,易于理解的方式来访问数据成员。 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号