Найдите в или в интернете характеристики современных микропроцессоров,устройств статической и динамической памяти,внешних запоминающих устройств,устройств отображения информации (вывода) и сравните их с аналогичными характеристиками устройств первых эвм. выполните в виде таблицы
class Program
{
static void Main()
{
var random = new Random(DateTime.Now.Millisecond);
int n = 3;
var f = new int[n, n];
int c;
Console.WriteLine("f:");
for (var i = 0; i < n; i++)
{
for (var j = 0; j < n; j++)
{
f[i, j] = random.Next(0, 9);
Console.Write(f[i, j] + " ");
}
Console.WriteLine();
}
Console.WriteLine();
for(int i = 0; i < n; i++) {
if (f[i,0] != f[i,i]){
c = f[i,0]; f[i,0] = f[i,i]; f[i,i] = c;
}
}
Console.WriteLine("New f:");
for(int i = 0; i < n; i++){
for (var j = 0; j < n; j++)
Console.Write(f[i,j] + " ");
Console.WriteLine();
}
Console.WriteLine();
Console.ReadKey();
}
}
Пример:
f:
8 1 0
3 6 3
0 5 7
New f:
8 1 0
6 3 3
7 5 0
Пример ввода:
4
x100+12mamba+11=barry-3
7x100-4barry=4
barry=x100-2mamba
4=2+2
Пример вывода:
barry=6
mamba=-1
x100=4
#include <iostream>
#include <map>
#include <string>
#include <set>
#include <vector>
#define abs(x) ((x)<0 ? -(x) : (x))
using namespace std;
typedef map<string, double> equation;
equation parseLine(const string &str, set<string> &vars) {
map<string, double> eqn;
bool left_part = true;
size_t i = 0;
while (i < str.length()) {
double n = 0;
bool isNeg = !left_part;
bool isCoeffOmitted = true;
string var = "";
if (str[i] == '='){
left_part = false;
i++;
continue;
}
if ((str[i] == '-') || (str[i] == '+'))
{
if (str[i] == '-') isNeg = !isNeg;
i += 1;
}
while ((i < str.length()) && (str[i] >= '0') && (str[i] <= '9')) {
n = 10 * n + (str[i] - '0');
isCoeffOmitted = false;
i++;
}
if ((i < str.length()) && (str[i] == '.')) {
int exp = 0;
i++;
while ((i < str.length()) && (str[i] >= '0') && (str[i] <= '9')){
n = 10 * n + (str[i] - '0');
exp++;
i++;
}
for (int j = 0; j < exp; n /= 10., j++);
}
while ((i < str.length()) && (str[i] != '+') && (str[i] != '=') && (str[i] != '-')){
var += str[i];
i++;
}
if (isCoeffOmitted) n = 1;
if (isNeg) n = -n;
eqn[var] += n;
vars.insert(var);
}
return eqn;
}
void GaussJordan(vector<equation> &eqns, const vector<string> &vars) {
for (size_t i = 0; i < vars.size(); i++) {
size_t j = i;
while ((j < eqns.size()) && (eqns[j][vars[i]] == 0))
j++;
if (j == eqns.size()) throw "Underdetermined system";
if (j != i) swap(eqns[i], eqns[j]);
double elem = eqns[i][vars[i]];
for (equation::iterator it = eqns[i].begin(); it != eqns[i].end(); it++)
it->second /= elem;
for (j = i + 1; j < eqns.size(); j++){
elem = eqns[j][vars[i]];
for (equation::iterator it = eqns[i].begin(); it != eqns[i].end(); it++)
eqns[j][it->first] -= elem * eqns[i][it->first];
}
}
for (size_t i = vars.size(); i < eqns.size(); i++)
for (equation::iterator it = eqns[i].begin(); it != eqns[i].end(); it++)
if (abs(it->second) > 1e-12) throw "No solutions";
for (size_t i = vars.size() - 1; i > 0; i--) {
for (size_t j = 0; j < i; j++) {
eqns[j][""] -= eqns[j][vars[i]] * eqns[i][""];
eqns[j][vars[i]] = 0;
}
}
}
void printAnswer(vector<equation> &eqns, vector<string> &vars) {
for (size_t i = 0; i < vars.size(); i++)
cout << vars[i] << "=" << -eqns[i][""] << endl;
}
int main() {
set<string> vars;
vector<equation> eqns;
size_t n = 0;
cin >> n;
for (size_t i = 0; i < n; i++) {
string t;
cin >> t;
eqns.push_back(parseLine(t, vars));
}
vars.erase("");
vector<string> vars_list(vars.begin(), vars.end());
try {
GaussJordan(eqns, vars_list);
}
catch (char const *e) {
cout << e;
return 1;
}
printAnswer(eqns, vars_list);
return 0;
}