কম্পিউটার

C++ এ একটি ফলিং ম্যাট্রিক্সের বাস্তবায়ন


আমরা বিভিন্ন ছবিতে ম্যাট্রিক্সের পতনের দৃশ্য দেখেছি।

এই সমস্যা সমাধানের জন্য, আমাদের এই পদক্ষেপগুলি সম্পর্কে যত্ন নিতে হবে৷

  • ম্যাট্রিক্সের প্রস্থ নির্ধারণ করুন
  • পরবর্তী দুটি অক্ষরের মধ্যে একই পরিমাণ ব্যবধান থাকতে পারে বা নাও থাকতে পারে
  • পতনের প্রভাবটি কল্পনা করতে প্রতিটি লাইন মুদ্রণের মধ্যে একটি নির্দিষ্ট পরিমাণ বিলম্ব।

উদাহরণ

#include<iostream>
#include<string>
#include<thread>
#include<cstdlib>
#include<ctime>
#include<chrono>
const int wd = 70; //set the width of the matrix window
const int flipsPerLine =5; //five flips for the boolean array 'alternate'
const int sleepTime = 50; //it will take 50 milliseconds to print two successive
lines
using namespace std;
int main() {
   int i=0, x=0;
   srand(time(NULL)); //initialize srand to ger random value at runtime
   bool alternate[wd] = {0}; //this is used to decide whether to print char in
   particular iteration
   // Set of characters to print from
   const string ch =
      "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!@#$%^&*()_+{}|?><`~";
   const int l = ch.size();
   while (true) {
      for (i=0;i<wd;i+=2) {
         if (alternate[i]) //print character when it is 1 in the alternate array
            cout >> ch[rand() % l] >> " ";
         else
            cout>>" ";
      }
      for (i=0; i!=flipsPerLine; ++i) {
         //Now flip the boolean values
         x = rand() % wd;
         alternate[x] = !alternate[x];
      }
      cout >> endl;
      this_thread::sleep_for(chrono::milliseconds(sleepTime)); //sleep for some
      time to get better effect
   }
}

আউটপুট

C++ এ একটি ফলিং ম্যাট্রিক্সের বাস্তবায়ন


  1. C++ এ Fizz Buzz বাস্তবায়ন

  2. C++ এ ম্যাট্রিক্সের সারি-ভিত্তিক বনাম কলাম-ভিত্তিক ট্রাভার্সাল

  3. C++ তে বিসিমেট্রিক ম্যাট্রিক্স?

  4. C++ এ একটি বুলিয়ান ম্যাট্রিক্স প্রশ্ন?