Напишете функции, които:
- отпечатват числата от 1 до N, разделени с указан като параметър символ
- намират сумата на числата от 1 до N
С тяхна помощ направете програма, отпечатваща следното:
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 + 2 + 3 = 6
1 + 2 + 3 + 4 = 10
1 + 2 + 3 + 4 + 5 = 15
1 + 2 + 3 + 4 + 5 + 6 = 21
1 + 2 + 3 + 4 + 5 + 6 + 7 = 28


#include <cstdlib> #include <iostream> using namespace std; void pechat(int n, char s) { for(int i=1; i<=n; i++) cout<<i<<s ; } int suma (int n) { int sum=0; for(int i=1; i<=n; i++) sum=sum+i ; return sum; } int main(int argc, char *argv[]) { pechat(1,' '); cout<<endl ; pechat(2,' ');cout<<endl ; pechat(3,' ');cout<<endl ; pechat(4,' ') ;cout<<endl ; pechat(5,' ');cout<<endl<<endl ; pechat(3,'+');cout<<'='<<suma(3)<<endl; pechat(4,'+');cout<<'='<<suma(4)<<endl; pechat(5,'+');cout<<'='<<suma(5)<<endl; pechat(6,'+');cout<<'='<<suma(6)<<endl; pechat(7,'+');cout<<'='<<suma(7)<<endl; system("PAUSE"); return EXIT_SUCCESS; }#include <cstdlib> #include <iostream> using namespace std; void pechat(int n, char simvol) { int i=1; while (i<=n) { cout<<i<<simvol; i++; } } int suma(int n) { int s=0; int i=1; while (i<=n) { s=s+i; i++; } return s; } int main(int argc, char *argv[]) { system("Notepad C:\\Work\\testfile.txt"); pechat(1, ' '); cout<<endl; pechat(2, ' '); cout<<endl; pechat(3, ' '); cout<<endl; pechat(4, ' '); cout<<endl; pechat(5, ' '); cout<<endl; cout<<endl; pechat(3, '+'); cout<<"="<<suma(3)<<endl; pechat(4, '+'); cout<<"="<<suma(4)<<endl; pechat(5, '+'); cout<<"="<<suma(5)<<endl; pechat(6, '+'); cout<<"="<<suma(6)<<endl; pechat(7, '+'); cout<<"="<<suma(7)<<endl; cout<<endl; cout<<suma(10)<<endl; system("PAUSE"); return EXIT_SUCCESS; }