কম্পিউটার

সি++ এ মাল্টিডাইমেনশনাল অ্যারের ডাইমেনশন কিভাবে প্রিন্ট করবেন


প্রদত্ত অ্যারের মাত্রা প্রিন্ট করার জন্য এখানে একটি C++ প্রোগ্রাম রয়েছে৷

অ্যালগরিদম

Here template() function is used to find out the current size of array.
Then recursively call it till the last dimension of array.

উদাহরণ কোড

#include <iostream>
using namespace std;
template <typename t, size_t n>
void printDimensionsOfArray(const t (&a)[n]) {
   cout << n;
}
template <typename t, size_t n, size_t m>
void printDimensionsOfArray(const t (&a)[n][m]) {
   cout << "Dimensions of the Array is: "<<n << " x ";
   printDimensionsOfArray(a[0]);
}
int main() {
   int a[6][7];
   printDimensionsOfArray(a);
   return 0;
}

আউটপুট

Dimensions of the Array is: 6 x 7

  1. C/C++ এ একটি বহুমাত্রিক অ্যারে শুরু করা

  2. সি-তে বহুমাত্রিক অ্যারে

  3. আমি কিভাবে নতুন ব্যবহার করে C++ এ একটি 2d ​​অ্যারে ঘোষণা করব

  4. আমি কিভাবে C++ এ অ্যারে ব্যবহার করব?