UVa 327 Evaluating Simple C Expressions
/*
coder: ACboy
date: 2010-3-14
result: 1A
description: UVa 327 Evaluating Simple C Expressions
*/
#include <iostream>
#include <algorithm>
using namespace std;
struct Node {
char name;
int value;
int lastValue;
int pos;
};
int cmp(const Node & a, const Node & b)
{
return a.name < b.name;
}
Node data[30];
int vis[256];
int main()
{
char input[256];
char temp[256];
char Temp[256];
#ifndef ONLINE_JUDGE
freopen("327.txt", "r", stdin);
#endif
while (gets(input))
{
int i, j;
int c = 0;
int count = 0;
int len = strlen(input);
for (i = 0; i < len; i++)
{
if (input[i] != ' ') {
temp[c++] = input[i];
if (isalpha(input[i])) {
data[count].name = input[i];
data[count].value = input[i] - 'a' + 1;
data[count].lastValue = data[count].value;
data[count].pos = c - 1;
count++;
}
}
temp[c] = '\0';
}
memset(vis, 0, sizeof(vis));
for (i = 0; i < count; ++i) {
int pos = data[i].pos;
if (pos - 2 >= 0) {
if (temp[pos - 1] == temp[pos - 2] && temp[pos - 1] == '-') {
data[i].value--;
data[i].lastValue = data[i].value;
vis[pos - 1] = 1;
vis[pos - 2] = 1;
}
if (temp[pos - 1] == temp[pos - 2] && temp[pos - 1] == '+') {
data[i].value++;
data[i].lastValue = data[i].value;
vis[pos - 1] = 1;
vis[pos - 2] = 1;
}
}
if (pos + 2 < len) {
if (temp[pos + 1] == temp[pos + 2] && temp[pos + 1] == '-') {
data[i].lastValue = data[i].value - 1;
vis[pos + 1] = vis[pos + 2] = 1;
}
if (temp[pos + 1] == temp[pos + 2] && temp[pos + 1] == '+') {
data[i].lastValue = data[i].value + 1;
vis[pos + 1] = vis[pos + 2] = 1;
}
}
}
c = 0;
for (i = 0; i < len; ++i)
{
if (!vis[i]) {
Temp[c++] = temp[i];
}
}
Temp[c] = '\0';
len = strlen(Temp);
Ïà¹ØÎĵµ£º
ÉèÏëÖеÄCÍøÂç¿âioframe is a simple base socket library using libevent.http://blog.csdn.net/Solstice/archive/2010/03/10/5364096.aspx
°´ÕÕ
µÄ˼ÏëÌá½»µÄÒ»·Ý´úÂë¡£
ÉèÏëÖÐµÄ C++ ÍøÂç¿âḬ̈߳²È«£¬Ö§³Ö¶àºË¶àÏß³ÌÔÚ²»Ôö¼Ó¸´ÔӶȵÄǰÌáÏ¿ÉÒÔÖ§³Ö FreeBSD/Darwin£¬·½±ã½«À´Óà Mac ×÷Ϊ¿ª·¢Óûú£¬µ«²»ÎªËü×öÐÔÄÜ ......
C++ÌṩµÄ±àÒëÔ¤´¦Àí¹¦ÄÜÖ÷ÒªÓÐÒÔÏÂÈýÖÖ£º
¡¡¡¡£¨Ò»£© ºê¶¨Òå
¡¡¡¡£¨¶þ£© Îļþ°üº¬
¡¡¡¡£¨Èý£© Ìõ¼þ±àÒë
¡¡¡¡ÔÚC++ÖУ¬ÎÒÃÇÒ»°ãÓÃconst¶¨Òå·ûºÅ³£Á¿¡£ºÜÏÔÈ»£¬ÓÃconst¶¨Òå³£Á¿±ÈÓÃdefine¶¨Òå³£Á¿¸üºÃ¡£
¡¡¡¡ÔÚʹÓú궨ÒåʱӦעÒâµÄÊÇ£º
¡¡¡¡£¨a£© ÔÚÊéд#define ÃüÁîʱ£¬×¢Òâ<ºêÃû>ºÍ<×Ö·û´®>Ö®¼äÓÿո ......
1¡¢ һЩͷÎļþµÄ×÷Óãº
<assert.h>£ºANSI C¡£Ìṩ¶ÏÑÔ£¬assert(±í´ïʽ)
<glib.h>£ºGCC¡£GTK£¬GNOMEµÄ»ù´¡¿â£¬ÌṩºÜ¶àÓÐÓõĺ¯Êý£¬ÈçÓÐÊý¾Ý½á¹¹²Ù×÷º¯Êý¡£Ê¹ÓÃglibÖ»ÐèÒª°üº¬<glib.h>
<dirent.h>£ºGCC¡£Îļþ¼Ð²Ù×÷º¯Êý¡£struct dirent,struct DIR,opendir(),closedir(),readdir(),readdi ......
¸ù¾ÝACM¹Ù·½ÍøÕ¾3ÔÂ9ÈÕ·¢²¼µÄÏûÏ¢£¬2009ÄêͼÁé½±ÊÚÓèÁËÏÖ´úPCÖ®¸¸Charles Thacker£¬ÒÔ±íÕÃËû¶ÔµÚһ̨ÏÖ´ú¸öÈ˼ÆËã»úXerox PARC AltoµÄÏÈÇýÐÔÉè¼ÆÓëʵÏÖ£¬»¹ÓÐÔÚ¾ÖÓòÍø£¨°üÀ¨ÒÔÌ«Íø£©¡¢¶à´¦ÀíÆ÷¹¤×÷Õ¾¡¢¿ú̽¸ßËÙ»º´æÒ»ÖÂÐÔÐÒéºÍƽ°åPCµÈ·½ÃæµÄÖØ´ó·¢Ã÷ºÍ¹±Ï×£¨For the pioneering design andРrealization of the fi ......
1¡¢ int a=2,b=11,c=a+b++/a++; ÔòcֵΪ¶àÉÙ£¿
¡¾¿¼µã¡¿±àÂë¹æ·¶¡£
±íÃæÉÏ¿¼²ìÄã¶ÔÔËËã·ûÓÅÏȼ¶µÄÕÆÎճ̶ȣ¬µ«Êµ¼ÊÉÏÓÅÏȼ¶ÕâÐ©ÍæÒâºÜÄÑËÀ¼ÇÓ²±³µÃס£¿´ó¼ÒµÄÒɻ󲻾ÍÊÇÔËËã·ûµÄ½áºÏ˳Ðòô£¿ÄÇôÈçºÎÈ¥±ÜÃâÄØ£¿c=a+((b++)/(a++))²»¾ÍÐÐÁËô£¬ÆäʵÎÊÌâ±³ºó¿¼²ìµÄÊÇÄãµÄ±àÂë¹æ·¶£¬ÈçºÎдÇåÎúÒ×¶®µÄ´úÂ룬ÈçºÎÔÚÒ»¸öÍÅ ......