易截截图软件、单文件、免安装、纯绿色、仅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
    {


相关文档:

高质量C++/C编程指南

http://man.lupaworld.com/content/develop/c&c++/c/c.htm
1. 如果参数是指针,且仅作输入用,则应在类型前加const,以防止该指针在函数体内被意外修改
2. 在函数体的“入口处”,对参数的有效性进行检查
    在函数体的“出口处”,对return语句的正确性和效率进行检 ......

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的位置
指向该位置的指针,未找到则返回空指针
......

在Eclipse中开发C/C++项目 转帖


C/C++ development with the Eclipse Platform
Pawel Leszek
 
摘要:通过本文你将获得如何在Eclipse平台上开发C/C++项目的总体认识。虽然Eclipse主要被用来开发Java项目,但它的框架使得它很容易实现对其他开发语言的支持。在这篇文章里,你将学会如何使用CDT(C/C++ Development Toolkit),一个在Eclipse平台上最 ......

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 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号