laba 6 (4/5 вариант)
unknown
plain_text
3 years ago
785 B
12
Indexable
#include <iostream>
using namespace std;
int main() {
int n, s = 0;
cout << "Введите n: ";
cin >> n;
for(int i=1; i<=n; i++) s+= i;
cout << "Результат: " << s;
}
/*
#include <iostream>
using namespace std;
long double fact(int K)
{
if(K < 0) return 0;
if (K == 0) return 1;
else return K * fact(K - 1);
}
int main() {
while (true)
{
long int k, s=1;
cout << "Введите k: ";
cin >> k;
if (k>=9){
for(int i=1; i<10; i++)
{
s*=k;
cout << "Результа k в степени 9: " << s << endl;
}
cout << "ИТОГ: " << s << endl;
}
else { cout << "Результа k!: " << fact(k) << endl << endl; }
}
}
*/
Editor is loading...