+ 1

The symbol s and the natural numbers n,m are given. n and m are odd numbers.print a rectangular frame and plus inside

The symbol s and the natural numbers n, m are given. n and m are odd numbers. Print a rectangular frame of s characters with size n x m, and a plus inside.

4th Nov 2020, 1:38 PM
Ruslan
11 Antworten
0
else if(i==N/2 || j==M/2 )cout << s; Add this condition also..Ruslan
4th Nov 2020, 2:29 PM
Jayakrishna 🇮🇳
+ 1
thank you!!!
4th Nov 2020, 2:32 PM
Ruslan
+ 1
so,i need “X” inside rectangular frame of s characters with size n x m
4th Nov 2020, 2:34 PM
Ruslan
0
Post your try..
4th Nov 2020, 1:43 PM
Jayakrishna 🇮🇳
0
#include <iostream> using namespace std; int main() { char s; cin » s; int N,M; cin » N»M; for (int i = 0; i < N; i++) { for (int j = 0; j < M; j++) { if (i == 0 || i == N - 1 ) cout « s; else if (j == 0 || j == M - 1) cout « s; else cout « " "; } cout « endl; } }
4th Nov 2020, 1:46 PM
Ruslan
0
Your program works fine but use << for in cin, cout. (double less than symbols, the symbol you are using is wrong one). And adjust output as charecter width if you need.. Edit : Ruslan #include <iostream> using namespace std; int main() { char s; cin >> s; int N,M; cin>> N>>M; for (int i = 0; i < N; i++) { for (int j = 0; j < M; j++) { if (i == 0 || i == N - 1 ) cout << s; else if (j == 0 || j == M - 1) cout <<s; else cout << "O"; } cout <<endl; } }
4th Nov 2020, 1:54 PM
Jayakrishna 🇮🇳
0
You have to use >> and << like Jayakrishna🇮🇳 said. If you save your code in code Playground and link it here it is easier to help you. Please clarify what is meant by "a plus inside"
4th Nov 2020, 2:01 PM
Benjamin Jürgens
Benjamin Jürgens - avatar
0
The symbol s and the natural numbers n, m are given. n and m are odd numbers. Print a rectangular frame of s characters with size n x m, and a plus inside.
4th Nov 2020, 2:17 PM
Ruslan
0
this code just create rectangle frame , i need a rectangular fram of s characters with size n x m, and plus inside
4th Nov 2020, 2:18 PM
Ruslan
0
Example: Input: # 7 5 Conclusion: ##### # # # # # # ##### # # # # # # #####.
4th Nov 2020, 2:20 PM
Ruslan
0
It's your wish. Adding space looks like something missing as it's width looks like is less than charecter.(it's a lower letter). So if you add anything other than space you can see clearly that it's getting correct or not..
4th Nov 2020, 2:37 PM
Jayakrishna 🇮🇳