স্ট্রিং-এর অ্যারে দেওয়া আছে। প্রতিটি স্ট্রিং-এর স্কোর = (স্ট্রিং-এর পজিশন) × (ক্যারেক্টারগুলোর অ্যালফাবেটিক্যাল ভ্যালুর যোগফল)। a=1, b=2, ..., z=26।
ইনপুট
str[] = {"learn", "programming", "tutorials", "point"}
আউটপুট
Score of 'learn': 50 (pos 1, sum=50) Score of 'programming': 262 (pos 2, sum=131) Score of 'tutorials': 405 (pos 3, sum=135) Score of 'point': 296 (pos 4, sum=74)
এলগরিদম
- প্রতিটি স্ট্রিং এর জন্য পজিশন (১-বেসড) নিন।
- ক্যারেক্টার ট্রভার্স করে `ch - 'a' + 1` যোগ করুন।
- পজিশন × যোগফল = স্কোর।
উদাহরণ কোড
#include <iostream>
using namespace std;
int strScore(string str[], string s, int n, int index){
int score = 0;
for(int j=0; j
আউটপুট
Score of 'learn' = 50
Score of 'programming' = 262
Score of 'tutorials' = 405
Score of 'point' = 296