0

The symbol s and the natural number n are given. Print a square of s characters with size n x n.

The symbol s and the natural number n are given. Print a square of s characters with size n x n.

3rd Nov 2020, 5:13 PM
Ruslan
11 ответов
0
Copy your code to code Playground, then you can try yourself. You need closing brackets and cast to integer. Output must be in inner loop. Use j instead of i for inner loop. You are on the right track, keep going
4th Nov 2020, 11:01 AM
Benjamin Jürgens
Benjamin Jürgens - avatar
+ 1
thank you ❤️❤️❤️ i did it!!!
4th Nov 2020, 12:33 PM
Ruslan
+ 1
#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++) { cout « s; }cout « endl; } }
4th Nov 2020, 12:41 PM
Ruslan
0
Did you try it? Show us and say where you are stuck
3rd Nov 2020, 6:21 PM
Benjamin Jürgens
Benjamin Jürgens - avatar
0
i couldnt do it
4th Nov 2020, 6:20 AM
Ruslan
0
Do it like this: A for loop that prints s n times That gives you one line Another for loop around that that also loops n times That will give you n lines of n characters s
4th Nov 2020, 8:14 AM
Benjamin Jürgens
Benjamin Jürgens - avatar
0
char s[]; int n; cin>>n; for(int i=0;i<n;i++){ cin>>s[i];} like this ? what should i do next?
4th Nov 2020, 9:56 AM
Ruslan
0
N is int, so cast input to int S should be single char, no brackets Read s from input, cin>>s; In loop use output (cout) Add another loop around the first
4th Nov 2020, 10:18 AM
Benjamin Jürgens
Benjamin Jürgens - avatar
0
int N; cin>>N; char s; cin>>s; for(int i=0;i<N;i++){ cout<<s; for(int i=0;i<N;i++){
4th Nov 2020, 10:23 AM
Ruslan
0
Given the symbol s and the natural numbers n, m. Print a rectangular frame of s characters with size n x m.
4th Nov 2020, 12:41 PM
Ruslan
0
how to create a rectangle frame? should i change for loop?this code creates just rectangle
4th Nov 2020, 12:42 PM
Ruslan