Answer to Question #313921 in C++ for Ajay

Question #313921

Alex is found of doing string programs. One day his professor gave him a string based question to solve in a linear time complexity. The program is to change a strit to its diagonal string inter the form of X ( I. e Diagonal from left right and from right left) help him finish it


1
Expert's answer
2022-03-18T07:50:24-0400

Here is program:

int main() {
    srand(time(0));
    int a[n][n];
    for (int r = 0; r < n; ++r) {
        for (int c = 0; c < n; ++c) cout << setw(3) << (a[r][c] = rand() % 100);
        cout << endl;
    }
    cout << "Main: ";
    for (int c = 0; c < n; ++c) cout << setw(3) << a[c][c];
    cout << "Side: ";
    for (int c = 0; c < n; ++c) cout << setw(3) << a[c][n - 1 - c];
}

9
9
Нравится

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog