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);
Ïà¹ØÎĵµ£º
Linux I2CºËÐÄ¡¢×ÜÏßÓëÉ豸Çý¶¯
×¢:
ÔÚlinux2.6.32°æ±¾ÖÐÓÐÕâÑùµÄ´úÂëÓë×¢ÊÍ:
struct i2c_driver {
unsigned int class;
/* Notifies the driver that a new bus has appeared or is about to be
* removed. You should avoid using this if y ......
ÉùÃ÷£º´ËÎĵĸ÷ÖÖâ«Ëö½â·¨×ª×Ôµç×Ó¿Æ´óÄÚÍøÂÛ̳£¬¶Ô£¬¾ÍÊÇ×î½üÒò”ÐíÔ¸ÃÅ“¶øÉϸ÷´óÐÂÎÅÍøÕ¾µÄѧУ¡£
ÌâÄ¿ÈçÏ£º
#include "stdio.h"
void print()
{
*
}
void main()
{
}
ÒªÇóÔÚ*ºÅ´¦Ìí¼ÓÓï¾ä£¬³ÌÐòÊä³öhello,world!
ºÃÁË£¬ÎÒÖ±½ÓÌù´ð°¸ÁË£¬ÏàÐÅ´ó¼Ò¶¼¿´µÃ¶®£¬ÓÐЩʵÔÚÊÇâ«Ëö¡£¡£¡ ......
±¾ÎÄÀ´×Ô£º http://blog.pfan.cn/xiuandfang/24935.html
±êÇ©:C C ++ string String Êý¾Ý½á¹¹
C×Ö·û´®´¦Àíº¯ÊýµÄʵÏÖ
C×Ö·û´®´¦Àíº¯ÊýµÄʵÏÖ£¨Linux£©
#include <stddef.h>
char * ___strtok = NULL;
char * strcpy(char * dest,const char *src)
&nb ......
ת×Ô£ºhttp://www.bmrtech.com/article/2008/081126.htm
ûÈËÄÜ·ñÈÏǶÈëʽӦÓÃÕý±äµÃÔ½À´Ô½ÆÕ±é¡£µ«ÊÇ£¬µ±ÏµÍ³Ô½À´Ô½¸´ÔÓ£¬¶øÎÒÃǸ³ÓèϵͳԽÀ´Ô½¶àµÄÔðÈεÄʱºò£¬ÎÒÃǽ«±ØÐëÃæ¶ÔÒ»Ð©ÖØÒªÎÊÌâ¡£ÆäÖÐ×îÖØÒªµÄÎÊÌâÊÇ£ºÎÒÃÇÈçºÎ²ÅÄÜÈ·±£Ç¶ÈëʽϵͳÊǰ²È«¿É¿¿µÄ£¿
C ±à³ÌÓïÑÔΪÓû§ÌṩÁËÐí¶àÇ¿´óµÄ¹¦ÄÜ£¬¼ ......
¸ù¾ÝACM¹Ù·½ÍøÕ¾3ÔÂ9ÈÕ·¢²¼µÄÏûÏ¢£¬2009ÄêͼÁé½±ÊÚÓèÁËÏÖ´úPCÖ®¸¸Charles Thacker£¬ÒÔ±íÕÃËû¶ÔµÚһ̨ÏÖ´ú¸öÈ˼ÆËã»úXerox PARC AltoµÄÏÈÇýÐÔÉè¼ÆÓëʵÏÖ£¬»¹ÓÐÔÚ¾ÖÓòÍø£¨°üÀ¨ÒÔÌ«Íø£©¡¢¶à´¦ÀíÆ÷¹¤×÷Õ¾¡¢¿ú̽¸ßËÙ»º´æÒ»ÖÂÐÔÐÒéºÍƽ°åPCµÈ·½ÃæµÄÖØ´ó·¢Ã÷ºÍ¹±Ï×£¨For the pioneering design andРrealization of the fi ......