help pleaseeee

can anyone help me with printing the alphabet in this specific pattern?

A B C D E F
B C D E F
C D E F
D E F
E F
F
closed account (SECMoG1T)
is this an assignment?
std::cout << "A B C D E F\nB C D E F\nC D E F\nD E F\nE F\nF\n";
1
2
3
#include <iostream>
void decay( const char *p ) { if ( *p ) { std::cout << p << '\n';   decay( ++p ); } }
int main() { decay( "ABCDEF" ); }

or just
1
2
#include <iostream>
int main() { const char *p = "ABCDEF";   while ( *p ) std::cout << p++ << '\n'; }
Last edited on
i have to use a nested for loop. any help with that?
closed account (SECMoG1T)
here you go:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <iostream>
#include <string>

int main()
{
    std::string data("ABCDEF");

    for(std::size_t i =0; i<data.size(); i++)
    {
        for(std::size_t j= i ; j<data.size(); j++)
            std::cout<<data[j];

        std::cout<<std::endl;
    }
}
Topic archived. No new replies allowed.