list = []
while True:
n = int(input("nb: "))
if n == 0:
break
list.append(n)
res = 1
sum = sum(list)
for x in list:
if x * x > sum:
res *= x
print(res)
# 2def isPerfectSquare(num):
s = int(num**0.5)
return s * s == num
def isFibonacciNumber(n):
return isPerfectSquare(5 * n * n + 4) or isPerfectSquare(5 * n * n - 4)
list = []
while True:
n = int(input('nb : '))
if n % 2:
odd = n
break
list.append(n)
if isFibonacciNumber(n):
print([x for x in list if not(x % 3)])
else:
print([x for x in list if not(x % 5)])
# 3list = []
N = int(input('N = '))
for i in range(N):
n = int(input('nb : '))
list.append(n)
print(sum([x for x in list if x * x % 10 == 9]))
class Program
{
static void Main(string[] args)
{
string src = " Qwy. ... Asdf.. Lkjdfs A.";
//string dest = ReplaceDots(src, '.', '…', 3);
string dest = ReplaceDots(src, '.', "...", 3);
Console.WriteLine("src:\t" + src);
Console.WriteLine("dest:\t" + dest);
Console.WriteLine();
Console.Write("Press any key for exit ...");
Console.ReadKey(true);
}
//private static string ReplaceDots(string src, char dotCh, char dots, int minDotsCount)
private static string ReplaceDots(string src, char dotCh, string dots, int minDotsCount)
{
StringBuilder dest = new StringBuilder();
int i = 0;
while (i < src.Length)
{
int dotsCount = 0;
while (i < src.Length && src[i] == dotCh)
{
dotsCount++;
i++;
}
if (dotsCount >= minDotsCount)
dest.Append(dots);
else if (dotsCount == 0)
dest.Append(src[i++]);
else
while (dotsCount-- > 0)
dest.Append(dotCh);
}
return dest.ToString(); ;
}
}
#include <iostream>
#include <array>
#include <algorithm>
#include <random>
#include <iterator>
const size_t size_matrix = 5;
int main()
{
std::random_device random;
std::mt19937 generator(random());
std::uniform_real_distribution<float> dist(1.0, 100.0);
std::array<float, size_matrix> matrix[size_matrix];
for (size_t i = 0; i < size_matrix; i++)
{
std::for_each(matrix[i].begin(), matrix[i].end(), [&generator, &dist](auto& var)
{
var = dist(generator);
});
}
for (size_t i = 0; i < size_matrix; i++)
{
std::copy(matrix[i].begin(), matrix[i].end(),
std::ostream_iterator<float>(std::cout, " "));
std::cout << std::endl;
}
std::cout << "Result: " << std::endl;
for (size_t i = 0; i < size_matrix; i++)
std::cout << matrix[i][i] << std::endl;
std::system("PAUSE >> void");
return 0;
}