Răspuns :
Răspuns:
1. #include <iostream>
using namespace std;
int main()
{
int n = 0, suma = 0, k = 0;
cin >> n;
while( k <= n )
{
suma += k;
k++;
}
cout << suma;
return 0;
}
2. #include <iostream>
using namespace std;
int main()
{
int n = 0, suma = 0, k = 1;
cin >> n;
while( k <= n )
{
suma += k;
k += 2;
}
cout << suma;
return 0;
}
3.#include <iostream>
using namespace std;
int main()
{
int n = 0, suma = 0, k = 2;
cin >> n;
while( k <= n )
{
suma += k;
k += 2;
}
cout << suma;
return 0;
}
4. #include <iostream>
using namespace std;
int main()
{
int n = 0, suma = 1, k = 1;
cin >> n;
while( k <= n )
{
suma *= k;
++k;
}
cout << suma;
return 0;
}
5. #include <iostream>
using namespace std;
int main()
{
int n = 0, suma = 1, k = 1;
cin >> n;
while( k <= n )
{
suma *= k;
k += 2;
}
cout << suma;
return 0;
}
6. #include <iostream>
using namespace std;
int main()
{
int n = 0, suma = 1, k = 2;
cin >> n;
while( k <= n )
{
suma *= k;
k += 2;
}
cout << suma;
return 0;
}
7. #include <iostream>
using namespace std;
int main()
{
float n = 0, suma = 0, k = 2;
cin >> n;
while( k <= n )
{
suma += 1 / k;
++k;
}
cout << suma;
return 0;
}
8. #include <iostream>
using namespace std;
int main()
{
int n = 0, k = 1, suma = 0;
cin >> n;
while( k <= n )
{
suma += k * 10 + 3;
++k;
}
cout << suma;
return 0;
}
9. #include <iostream>
using namespace std;
int main()
{
float n = 0, k = 2, suma = 0;
cin >> n;
while( k <= n )
{
suma += ( k - 1 ) / k;
++k;
}
cout << suma;
return 0;
}
10. #include <iostream>
using namespace std;
int main()
{
int n = 0, k = 2, suma = 0;
cin >> n;
while( k <= n )
{
suma += ( k - 1 ) * k;
++k;
}
cout << suma;
return 0;
}
11. #include <iostream>
using namespace std;
int main()
{
float n = 0, k = 1, suma = 0;
cin >> n;
while( k <= n )
{
suma += ( k ) / ( 3 * k + 1 );
++k;
}
cout << suma;
return 0;
}
12. #include <iostream>
using namespace std;
int main()
{
int n = 0, k = 1, suma = 0;
cin >> n;
while( k <= n )
{
if( k % 2 == 1 )
suma -= k;
else
suma += k;
++k;
}
cout << suma;
return 0;
}
Explicație:
La cele cu impartire le-am facut sa iti dea cu virgula, de aia sunt float unele. As aprecia o coronita, a fost destul de mult de scris. :)
Vă mulțumim pentru vizita pe site-ul nostru dedicat Informatică. Sperăm că informațiile prezentate v-au fost utile. Dacă aveți întrebări sau aveți nevoie de suport suplimentar, nu ezitați să ne contactați. Ne bucurăm să vă revedem și vă invităm să ne adăugați în lista de favorite!