易截截图软件、单文件、免安装、纯绿色、仅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陷阱:判断宏是否等于一个常数

下面这段代码有啥错误?
#if ULONG_MAX == 0xFFFFFFFF
inline unsigned long byte_swap(unsigned long x) { return __builtin_bswap32(x); }
inline long byte_swap(long x) { return __builtin_bswap32(x); }
#else
inline unsigned long byte_swap(unsigned long x) { return __builtin_bswap64(x); }
inline long ......

C库函数(字符串函数)


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

linux环境下,c++库文件中的符号的含义

c++库文件中的符号的含义:
      所有的符号都是以下划线加上大写字母也就是"_Z"开头,对于在 类里或者命名空间中的符号,后面紧跟"N",然后是各个命名空间和类的名字,每个名字前是名字字符串的长度,随后是大写字母"E",对于一个函数,他的参数列表都在E后面, ......

【linux】c++ 内存管理(二)

3. 指针与数组的比较
不同点:
      数组:要么在惊天存储区域被创建(如全局数组),要么在栈上被创建。数组名对应着(而不是指向)一块内存,其地址与容量在生命周期内保持不变,只有数组的内容可以改变。
指针:可以随时指向任意类型的内存块,它的特征是“可变”,所以我们常用 ......

Objective C 2.0 属性(Property)

原帖一:http://blog.csdn.net/dotphoenix/archive/2009/05/20/4203075.aspx
原贴二:http://www.cocoachina.com/bbs/read.php?tid-8008.html
@property (参数) 类型 名字;
这里的参数主要分为三类:读写属性(readwrite/readonly),setter语意(assign/retain/copy)以及atomicity(nonatomic)。
assign/retain/copy ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号