ПЕРВАЯ ПРОГРАММА using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;
namespace Factorial { class Program {
static void Main(string[] args) { string str = ""; Console.WriteLine("Vvestu n:"); str = Console.ReadLine(); int n = Convert.ToInt32(str); Console.WriteLine(Enumerable.Range(1, n).Aggregate((p, x) => p * x)); Console.ReadKey(); } } }
Вторая программа (поменяй путь на свой!) using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Text; using System.Threading.Tasks;
namespace Open { class Program { static void Main(string[] args) { System.Diagnostics.Process.Start(@"T:\Program Files\Projects\Lessons\Factorial\Factorial\bin\Debug\Factorial.exe"); } } }
using namespace std;
int main()
{
int n, k;
cout << "n = ";
cin >> n;
cout << endl;
int a[n];
for (int i = 0; i < n; i++) {
cout << "a[" << i << "] = ";
cin >> a[i];
cout << endl;
}
cout << "k = ";
cin >> k;
cout << endl;
int c = 0;
for (int i = 0; i < n; i++) {
if (a[i] % 10 == k) c++;
}
int ret[c], pos = 0;
for (int i = 0; i < n; i++) {
if (a[i] % 10 == k) {
ret[pos] = a[i];
pos++;
}
}
cout << "Результат:" << endl;
for (int i = 0; i < c; i++) {
cout << ret[i] << ' ';
}
return 0;
}