Похожие чаты

Hi! How can i make this (C++)? H

HE
HEL
HELL
HELLO

13 ответов

11 просмотров

use loop inside loop. inner loop for iterating letters and spaces. external - for iterating rows

no. this code works. but look at this from another side. what if you need to do the same with another word e.g. "world"? or what if word is 100500 letters long?

maybe a FOR loop ?

علیرضا
Please send me a better solution

no. this chat is for explaining, but not for giving final solutions. just try to write next: 1. your word is an array of symbols 2. loop iterating from 0 to word length minus 1 (which means you iterating rows) 3. loop inside previous from 0 to previous loop index 4. inside this loop print symbol 5. if you need to print spaces before symbols to draw triangle - just calculate the count length/2-inner index

Mihai
maybe a FOR loop ?

include <iostream> using namespace std; int main() { for (string i = H; i < HELLO; i++) {   if (i == HELLO) {     break;   }   cout << i << "\n"; }  return 0; }

artemetra 🇺🇦 [less active]
i++ is not defined for std::string

Language C++ Input include <iostream> using namespace std; int main() { for (string i = H; i < HELLO; i++) {   if (i == HELLO) {     break;   }   cout << i << "\n"; }  return 0; } Output /usercode/file.cpp:5:4: error: stray '\302' in program for (string i = H; i < HELLO; i++) { ^ /usercode/file.cpp:5:5: error: stray '\240' in program for (string i = H; i < HELLO; i++) { ^ /usercode/file.cpp:5:13: error: stray '\302' in program for (string i = H; i < HELLO; i++) { ^ /usercode/file.cpp:5:14: error: stray '\240' in program for (string i = H; i < HELLO; i++) { ^ /usercode/file.cpp:5:18: error: stray '\302' in program for (string i = H; i < HELLO; i++) { ^ /usercode/file.cpp:5:19: error: stray '\240' in program for (string i = H; i < HELLO; i++) { ^ /usercode/file.cpp:5:26: error: stray '\302' in program for (string i = H; i < HELLO; i++) { ^ /usercode/file.cpp:5:27: error: stray '\240' in program for (string i = H; i < HELLO; i++) { ^ /usercode/file.cpp:6:1: error: stray '\302' in program   if (i == HELLO) { ^ /usercode/file.cpp:6:2: error: stray '\240' in program   if (i == HELLO) { ^ /usercode/file.cpp:6:3: error: stray '\302' in program   if (i == HELLO) { ^ /usercode/file.cpp:6:4: error: stray '\240' in program   if (i == HELLO) { ^ /usercode/file.cpp:6:7: error: stray '\302' in program   if (i == HELLO) { ^ /usercode/file.cpp:6:8: error: stray '\240' in program   if (i == HELLO) { ^ /usercode/file.cpp:6:14: error: stray '\302' in program   if (i == HELLO) { ^ /usercode/file.cpp:6:15: error: stray '\240' in program   if (i == HELLO) { ^ /usercode/file.cpp:7:1: error: stray '\302' in program     break; ^ /usercode/file.cpp:7:2: error: stray '\240' in program     break; ^ /usercode/file.cpp:7:3: error: stray '\302' in program     break; ^ /usercode/file.cpp:7:4: error: stray '\240' in program     break; ^ /usercode/file.cpp:7:5: error: stray '\302' in program     break; ^ /usercode/file.cpp:7:6: error: stray '\240' in program     break; ^ /usercode/file.cpp:7:7: error: stray '\302' in program     break; ^ /usercode/file.cpp:7:8: error: stray '\240' in program     break; ^ /usercode/file.cpp:8:1: error: stray '\302' in program   } ^ /usercode/file.cpp:8:2: error: stray '\240' in program   } ^ /usercode/file.cpp:9:1: error: stray '\302' in program   cout << i << "\n"; ^ /usercode/file.cpp:9:2: error: stray '\240' in program   cout << i << "\n"; ^ /usercode/file.cpp:9:16: error: stray '\302' in program   cout << i << "\n"; ^ /usercode/file.cpp:9:17: error: stray '\240' in program   cout << i << "\n"; ^ /usercode/file.cpp:10:2: error: stray '\302' in program }  ^ /usercode/file.cpp:10:3: error: stray '\240' in program }  ^ /usercode/file.cpp:1:1: error: 'include' does not name a type include <iostream> ^~~~~~~ /usercode/file.cpp: In function 'int main()': /usercode/file.cpp:5:7: error: 'string' was not declared in this scope for (string i = H; i < HELLO; i++) { ^~~~~~ /usercode/file.cpp:5:7: note: suggested alternative: 'struct' for (string i = H; i < HELLO; i++) { ^~~~~~ struct /usercode/file.cpp:5:23: error: 'i' was not declared in this scope for (string i = H; i < HELLO; i++) { ^ /usercode/file.cpp:5:28: error: 'HELLO' was not declared in this scope for (string i = H; i < HELLO; i++) { ^~~~~ /usercode/file.cpp:9:4: error: 'cout' was not declared in this scope   cout << i << "\n"; ^~~~

artemetra 🇺🇦 [less active]
i++ is not defined for std::string

using namespace std in the top of the code The problem is another

#include <iostream> #include <string> using namespace std; void print(const string text) { for (int i(0); i < text.size(); i++) { for (int j(0); j <= i; j++) cout << text.at(j); cout << '\n'; } } int main() { print("HELLO"); return 0; }

Похожие вопросы

Обсуждают сегодня

Господа, а что сейчас вообще с рынком труда на делфи происходит? Какова ситуация?
Rꙮman Yankꙮvsky
29
А вообще, что может смущать в самой Julia - бы сказал, что нет единого стандартного подхода по многим моментам, поэтому многое выглядит как "хаки" и произвол. Короче говоря, с...
Viktor G.
2
@Benzenoid can you tell me the easiest, and safest way to bu.y HEX now?
Živa Žena
20
This is a question from my wife who make a fortune with memes 😂😂 About the Migration and Tokens: 1. How will the old tokens be migrated to the new $LGCYX network? What is th...
🍿 °anton°
2
30500 за редактор? )
Владимир
47
а через ESC-код ?
Alexey Kulakov
29
What is the Dex situation? Agora team started with the Pnetwork for their dex which helped them both with integration. It’s completed but as you can see from the Pnetwork ann...
Ben
1
Гайс, вопрос для разносторонее развитых: читаю стрим с юарта, нада выделять с него фреймы с определенной структурой, если ли чо готовое, или долбаться с ринг буффером? нада у...
Vitaly
9
Anyone knows where there are some instructions or discort about failed bridge transactions ?
Jochem
21
@lozuk how do I get my phex copies of my ehex from a atomic wallet, to move to my rabby?
Justfrontin 👀
11
Карта сайта