এই প্রবন্ধে, আমরা বুঝতে পারব কিভাবে প্রদত্ত স্ট্রিংটি প্যানগ্রাম কিনা। একটি স্ট্রিং একটি প্যানগ্রাম স্ট্রিং যদি এটিতে বর্ণমালার ক্ষেত্রে উপেক্ষা করে বর্ণমালার সমস্ত অক্ষর থাকে৷
নীচে একই -
এর একটি প্রদর্শন রয়েছে৷ধরুন আমাদের ইনপুট হল −
Input string: Abcdefghijklmnopqrstuvwxyz
কাঙ্খিত আউটপুট হবে −
Yes, the string is a pangram
অ্যালগরিদম
Step 1 - START Step 2 - Declare a string value namely input_string. Step 3 - Define the values. Step 4 - Convert the input string to a character array. Step 5 - Iterate over the character of the array and check if the array contains all the alphabets using charAt(i) - 'a'. If yes, it’s a Pangram string. Step 6 - Display the result Step 7 - Stop
উদাহরণ 1
এখানে, আমরা 'প্রধান' ফাংশনের অধীনে সমস্ত ক্রিয়াকলাপ একসাথে আবদ্ধ করি।
public class Pangram {
static int size = 26;
static boolean isLetter(char ch) {
if (!Character.isLetter(ch))
return false;
return true;
}
public static void main(String args[]) {
String input_string = "Abcdefghijklmnopqrstuvwxyz";
System.out.println("The string is defined as: " +input_string);
int string_length = input_string.length();
input_string = input_string.toLowerCase();
boolean[] is_true = new boolean[size];
for (int i = 0; i < string_length; i++) {
if (isLetter(input_string.charAt(i))) {
int letter = input_string.charAt(i) - 'a';
is_true[letter] = true;
}
}
boolean result;
for (int i = 0; i < size; i++) {
if (!is_true[i])
result = false;
}
result = true;
if (result)
System.out.println("\nYes, the string is a pangram");
else
System.out.println("\nNo, the string is not a pangram");
}
} আউটপুট
The string is defined as: Abcdefghijklmnopqrstuvwxyz Yes, the string is a pangram
উদাহরণ 2
এখানে, আমরা ক্রিয়াকলাপগুলিকে অবজেক্ট-ওরিয়েন্টেড প্রোগ্রামিং প্রদর্শনকারী ফাংশনে অন্তর্ভুক্ত করি।
public class Pangram {
static int size = 26;
static boolean isLetter(char ch) {
if (!Character.isLetter(ch))
return false;
return true;
}
static boolean check_alphabets(String input_string, int string_length) {
input_string = input_string.toLowerCase();
boolean[] is_true = new boolean[size];
for (int i = 0; i < string_length; i++) {
if (isLetter(input_string.charAt(i))) {
int letter = input_string.charAt(i) - 'a';
is_true[letter] = true;
}
}
for (int i = 0; i < size; i++) {
if (!is_true[i])
return false;
}
return true;
}
public static void main(String args[]) {
String input_string = "Abcdefghijklmnopqrstuvwxyz";
System.out.println("The string is defined as: " +input_string);
int string_length = input_string.length();
if (check_alphabets(input_string, string_length))
System.out.println("\nYes, the string is a pangram");
else
System.out.println("\nNo, the string is not a pangram");
}
} আউটপুট
The string is defined as: Abcdefghijklmnopqrstuvwxyz Yes, the string is a pangram