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++ÌṩµÄ±àÒëÔ¤´¦Àí¹¦ÄÜÖ÷ÒªÓÐÒÔÏÂÈýÖÖ£º
¡¡¡¡£¨Ò»£© ºê¶¨Òå
¡¡¡¡£¨¶þ£© Îļþ°üº¬
¡¡¡¡£¨Èý£© Ìõ¼þ±àÒë
¡¡¡¡ÔÚC++ÖУ¬ÎÒÃÇÒ»°ãÓÃconst¶¨Òå·ûºÅ³£Á¿¡£ºÜÏÔÈ»£¬ÓÃconst¶¨Òå³£Á¿±ÈÓÃdefine¶¨Òå³£Á¿¸üºÃ¡£
¡¡¡¡ÔÚʹÓú궨ÒåʱӦעÒâµÄÊÇ£º
¡¡¡¡£¨a£© ÔÚÊéд#define ÃüÁîʱ£¬×¢Òâ<ºêÃû>ºÍ<×Ö·û´®>Ö®¼äÓÿո ......
Ç°ÑÔ£ºÇ°¶Îʱ¼äÔÚCSDNµÄC++ÉçÇøÓöµ½Ò»¸öÐèÒª·â×°¿¼ÇÚ»ú½Ó¿ÚµÄ¶¯Ì¬¿â¸øJAVAµ÷ÓõÄÌû×Ó£¬¹´ÆðÁËÎÒ¶ÔJAVAµÄÎÞÏÞ»³Äî¡£ÔÚ´Ë£¬ÎÒÏë°ÑÕâÏî¼¼Êõ¼òµ¥ÔÙ½éÉÜһϡ£
Ò»¡¢¹ØÓÚJava Native Interface (JNI)
JNIÊÇJAVA±¾µØ±à³Ì½Ó¿Ú£¬ÊôÓÚJDKµÄÒ»²¿·Ö¡£ËüÔÊÐíJAVAÄܹ»²Ù×÷±¾µØAPI»òÓÉÆäËûÓïÑÔ±àдµÄ¶¯Ì¬¿â¡£²»¹ýµ±ÄãʹÓÃÕâÏî¼¼ÊõµÄʱºò£ ......
ÎÒ²»ÖªµÀÕâƪÎÄÕµÄ×÷ÕßÊÇË£¬µ«ÎÒÖªµÀ£¬Ëû¶ÔjavaÓÐÒ»ÖÖºÜÉîµÄÀí½â£¬ÆäʵÎÄÕÂÖв¢Ã»ÓÐÌåÏÖ³ö×÷Õ߶Ôjava¼¼ÊõÉî²ãÀí½â£¬µ«ÊÇ´ÓÎÄÖеÄÿһ¾ä»°ÖУ¬ÎÒ¸ÐÊܵ½ÁËһЩ¶«Î÷¡£ÕâÊÇһƪºÜºÃµÄÎÄÕ£¬Ò²¿ÉÒÔ°ïÖúºÜ¶àÈËÃÔãµÄÈ˽â¾öÎÊÌâ¡£´øÀ´ºÍ´ó¼Ò·ÖÏíһϡ£
Ç°²»¾ÃCSDN¿¯µÇÁËһƪ¡¶CÓïÑÔÒѾËÀÁË¡·µÄÎÄÕ£¬ÒýÆðÁËһЩÕùÂÛ¡£ÆäʵÄÇÆ ......
±¾ÎÄÀ´×Ô£º 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 ......
½ñÌìÔÚдµ½ÓÃcÀ´½âÎöpostÊý¾ÝµÄʱºòÐèÒªÓõ½Ò»¸öÊý×é±äÁ¿À´·ÅpostµÄËùÓÐÊý¾ÝµÈ×ÅÀ´½âÎö£¬²»ÏëÌ«ÀË·ÑÄÚ´æÁË¡£ÓÚÊÇÏë×ÅÏÈÉêÇëÒ»¸ö×î´óÍþ¶ûŶcontent_length´óСµÄÊý×éÔÙ˵¡£µ«ÊDz»ÔÊÐíÓñäÁ¿À´¡£±ÈÈç
int length = atoi(getenv("CONTENT_LENGTH"));
char params[length];
memset(params, '\0', length);
ÄÇôchar para ......