Muszę wykonać program, który wypisze jakąś ilość znaków np.5 Muszę to zrobić za pomocą pętli for, wiecie może jak to zrobić?
Ma to wyglądać mniej więcej tak:
$
$$
$$$
$$$$
$$$$$
0
0
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
int a;
cout<<"Ile znakow chcesz wypisac ?";
cin>>a;
for(int i=0; i<a; i++)
{
cout<<"$";
}
cout<<endl;
system("PAUSE");
return EXIT_SUCCESS;
}
0
#include <iostream>
#include <conio.h>
int main()
{
int w = 0;
std::cout << "Ile chcesz wypisac znakow?" << std::endl;
std::cin >> w;
for (int i = 0; i < w; ++i)
{
for (int j = 0; j <= i; ++j) std::cout << "$";
std::cout << std::endl;
}
getch();
}