POJ 3094.Quicksum

一种特殊的字符加法,主要考察字符应用,水题

题目大意:一种特殊的字符加法,按照题目所属即可

题目链接

#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <cstring>
#include <cmath>
#include <cstdlib>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;

int main(int argc, char** argv) {
	
	while(1)
	{
		int total = 0;
		char s[1005];
		gets(s);
		if(s[0]=='#')	break;
		for(int i=0;i<strlen(s);i++)
		{
			if(s[i]>='A'&&s[i]<='Z')
			{
				total += (i+1) * ( s[i]-'A' + 1 );
			}
		}
		printf("%d\n",total);		
	} 

	//system("pause");
	return 0;
}

猜你喜欢

转载自blog.csdn.net/curiousliu/article/details/81150743
POJ