Rysowanie litery "W" z gwiazdek w konsoli

0

Witam
Potrzebuje pomocy w narysowaniu litery W w konsoli za pomocą gwiazdek ale nie wiem jak sie do tego zabrać pomoże ktos?

10
**      ** 
**  **  ** 
**  **  ** 
**  **  ** 
**  **  ** 
**  **  ** 
 ***  ***  

0

A wytłumaczył byś jak to przekształcić na kod?

0

Użyj obiektu std::cout, to jest w każdym kursie.

0

Udało mi sie tylko tyle na pisać

#include <iostream>

using namespace std;
 int x, i, j;
int main()
{
    cout << "Podaj liczbe "<<endl;
    cin >> x;

  for (i=1; i<=x; i++)
  {
      for(j=1; j<=x; j++)
      {
          if(j==x-i )
            cout << "*" ;

            else
                cout <<" ";
      }
      cout << endl;
  }

    return 0;
}

i nie wiem jak kolejne ramiona do rysować

4
#include <iostream>

using namespace std;

int main() {
    cout << "**      **" << endl;
    cout << "**  **  **" << endl;
    cout << "**  **  **" << endl;
    cout << "**  **  **" << endl;
    cout << "**  **  **" << endl;
    cout << "**  **  **" << endl;
    cout << " ***  *** " << endl;
	
    return 0;
}
0

Ale po co jakieś pętle, jak możesz po prostu wrzucić literkę jako string?

0

Musi być w pętli bo takie mamy zadanie :)

8

Prosz:

#include <iostream>
 
using namespace std;
 
int main() {
    for (int i = 0; i < 1; ++i) {
        cout << "**      **" << endl;
        cout << "**  **  **" << endl;
        cout << "**  **  **" << endl;
        cout << "**  **  **" << endl;
        cout << "**  **  **" << endl;
        cout << "**  **  **" << endl;
        cout << " ***  ***" << endl;
     }

    return 0;
}
7
#include <iostream>
#include <bitset>
using namespace std;

int main() {
	int a[] = {0x303,0x030,0,0,0x2fd};
	int x = 0;
	bitset<12> b; 
	for(int ai: a) {
		x = x ^ ai;
		b = x;
		cout << b.to_string(' ', 'W') << '\n';
	}
	return 0;
}

Wynik:

  WW      WW
  WW  WW  WW
  WW  WW  WW
  WW  WW  WW
   WWW  WWW 

https://ideone.com/3zd4EJ

0
#include <iostream>
#include <string>
#include <functional>

std::string random_str() {
    auto len = rand();
    std::string result;
    for (size_t i = 0; i < len; ++i) {
        result += char(rand() % 0x5f + 0x20);
    }
    
    return result;
}

int main () {
    size_t hash_wanted = 9479933615249102185ull;
    std::string result;
    
    while (std::hash<std::string>{}(result) != hash_wanted) {
        result = random_str();
    }
    
    std::cout << result;
}
1

Dzięki wszystkim za pomoc ale chodzi mi o co innego tu taj mam polecenie.
Dokładny opis zadania jest w załączniku.
Udało się zostawiam to tu może się komuś przyda :)
#include <iostream>

using namespace std;
int x, i, j;
int main()
{
cout << "Podaj liczbe wieksza od 2 "<<endl;
cin >> x;

while (x < 2)
{
    cout << "Podales liczbe mniejsza od 2"<<endl;
    cin >> x;

}

for (i=0; i<x; ++i)

{

  for(j=0; j<4*x; j++)
  {
        if(j==i)
        cout << "*" ;
        else if(j+i==x+(x-1))
        cout << "*" ;
        else if(j==i+x+x)
        cout << "*" ;
        else if(j+i==3*x+(x-1))
        cout << "*" ;

        else
            cout <<" ";
  }
  cout << endl;

}
return 0;
}

1 użytkowników online, w tym zalogowanych: 0, gości: 1