Решение к задаче 1.
#include "stdafx.h"
#include <Windows.h>
#include <iostream>
#include <string>
using namespace std;
int main()
{
SetConsoleCP(1251);
SetConsoleOutputCP(1251);
cout << "1. Выводим в строку значения от 0 до 10 \n";
for (int i = 0; i <= 10; i++)
{
cout << i;
cout << ";";
}
system("pause");
return 0;
}
Решение к задаче 2.
#include "stdafx.h"
#include <Windows.h>
#include <iostream>
#include <string>
using namespace std;
int main()
{
SetConsoleCP(1251);
SetConsoleOutputCP(1251);
cout << "\n2. Выводим в строку значения от 10 до 0 \n";
for (int i = 10; i >= 0; i--)
{
cout << i;
cout << ";";
}
system("pause");
return 0;
}
Решение к задаче 3.
#include "stdafx.h"
#include <Windows.h>
#include <iostream>
#include <string>
using namespace std;
int main()
{
SetConsoleCP(1251);
SetConsoleOutputCP(1251);
cout << "\n3. Выводим в строку значения от 60 до 100 \n";
for (int i = 60; i <= 100; i++)
{
cout << i;
cout << ";";
}
system("pause");
return 0;
}
Решение к задаче 4.
#include "stdafx.h"
#include <Windows.h>
#include <iostream>
#include <string>
using namespace std;
int main()
{
SetConsoleCP(1251);
SetConsoleOutputCP(1251);
cout << "\n4. Выводим в строку значения от -39 до 100 \n";
for (int i = -39; i <= 100; i++)
{
cout << i;
cout << ";";
}
system("pause");
return 0;
}
Решение к задаче 5.
#include "stdafx.h"
#include <Windows.h>
#include <iostream>
#include <string>
using namespace std;
int main()
{
SetConsoleCP(1251);
SetConsoleOutputCP(1251);
cout << "\n5. Выводим в строку четные числа от 2 до 50\n";
for (int i = 2; i <= 50; i += 2)
{
cout << i;
cout << ";";
}
system("pause");
return 0;
}
Решение к задаче 6.
#include "stdafx.h"
#include <Windows.h>
#include <iostream>
#include <string>
using namespace std;
int main()
{
SetConsoleCP(1251);
SetConsoleOutputCP(1251);
cout << "\n6. Выводим в строку нечетные числа от 1 до 49\n";
for (int i = 1; i <= 49; i += 2)
{
cout << i;
cout << ";";
}
system("pause");
return 0;
}
Задачи на вложенные циклы и на матрицы с использованием операторов for и if на c++.
Решение к задаче 7.
#include "stdafx.h"
#include <Windows.h>
#include <iostream>
#include <string>
using namespace std;
int main()
{
SetConsoleCP(1251);
SetConsoleOutputCP(1251);
cout << "\n7. Выводим таблицу нулей 10x10\n";
for (int y = 1; y <= 10; y++)
{
for (int x = 1; x <= 10; x++)
{
cout << 0;
cout << " ";
}
cout << "\n";
}
system("pause");
return 0;
}
Решение к задаче 8.
#include "stdafx.h"
#include <Windows.h>
#include <iostream>
#include <string>
using namespace std;
int main()
{
SetConsoleCP(1251);
SetConsoleOutputCP(1251);
cout << "\n8. Выводим таблицу нулей с диагональю из единиц 10x10\n";
for (int y = 1; y <= 10; y++)
{
for (int x = 1;x <= 10;x++)
{
if(x==y)
cout << 1;
else
cout << 0;
cout << " ";
}
cout << "\n";
}
system("pause");
return 0;
}
Решение к задаче 9.
#include "stdafx.h"
#include <Windows.h>
#include <iostream>
#include <string>
using namespace std;
int main()
{
SetConsoleCP(1251);
SetConsoleOutputCP(1251);
cout << "\n9. Выводим таблицу с рамочкой \n";
for (int y = 1; y <= 10; y++)
{
for (int x = 1;x <= 10;x++)
{
if(x==1 || x==10 ||y==1 || y==10 )
cout << 1;
else
cout << 0;
cout << " ";
}
cout << "\n";
}
system("pause");
return 0;
}
Решения к задаче 10.
#include "stdafx.h"
#include <Windows.h>
#include <iostream>
#include <string>
using namespace std;
int main()
{
SetConsoleCP(1251);
SetConsoleOutputCP(1251);
cout << "\n10. Выводим таблицу с заливкой \n";
for (int y = 1; y <= 10; y++)
{
for (int x = 1;x <= 10;x++)
{
if(y<=5)
cout << 1;
else
cout << 0;
cout << " ";
}
cout << "\n";
}
system("pause");
return 0;
}
Решение к задаче 11.
#include "stdafx.h"
#include <Windows.h>
#include <iostream>
#include <string>
using namespace std;
int main()
{
SetConsoleCP(1251);
SetConsoleOutputCP(1251);
cout << "\n11. Выводим таблицу с заливкой \n";
for (int y = 1; y <= 10; y++)
{
for (int x = 1;x <= 10;x++)
{
if(y<=5)
cout << 0;
else
cout << 1;
cout << " ";
}
cout << "\n";
}
system("pause");
return 0;
}
Решение к задаче 12.
#include "stdafx.h"
#include <Windows.h>
#include <iostream>
#include <string>
using namespace std;
int main()
{
SetConsoleCP(1251);
SetConsoleOutputCP(1251);
cout << "\n12. Выводим таблицу с заливкой \n";
for (int y = 1; y <= 10; y++)
{
for (int x = 1;x <= 10;x++)
{
if(x<=5)
cout << 0;
else
cout << 1;
cout << " ";
}
cout << "\n";
}
system("pause");
return 0;
}
Решение к задаче 13.
#include "stdafx.h"
#include <Windows.h>
#include <iostream>
#include <string>
using namespace std;
int main()
{
SetConsoleCP(1251);
SetConsoleOutputCP(1251);
cout << "\n13. Выводим таблицу с заливкой \n";
for (int y = 1; y <= 10; y++)
{
for (int x = 1;x <= 10;x++)
{
if(x<=5)
cout << 1;
else
cout << 0;
cout << " ";
}
cout << "\n";
}
system("pause");
return 0;
}
Решение к задаче 14.
#include "stdafx.h"
#include <Windows.h>
#include <iostream>
#include <string>
using namespace std;
int main()
{
SetConsoleCP(1251);
SetConsoleOutputCP(1251);
cout << "\n14. Выводим таблицу с заливкой \n";
for (int y = 1; y <= 10; y++)
{
for (int x = 1;x <= 10;x++)
{
if(x>y)
cout << 1;
else
cout << 0;
cout << " ";
}
cout << "\n";
}
system("pause");
return 0;
}
Решение к задаче 15.
#include "stdafx.h"
#include <Windows.h>
#include <iostream>
#include <string>
using namespace std;
int main()
{
SetConsoleCP(1251);
SetConsoleOutputCP(1251);
cout << "\n15. Выводим таблицу с заливкой \n";
for (int y = 1; y <= 10; y++)
{
for (int x = 1;x <= 10;x++)
{
if(x>=10-y+1)
cout << 0;
else
cout << 1;
cout << " ";
}
cout << "\n";
}
system("pause");
return 0;
}
Решение к задаче 16.
#include "stdafx.h"
#include <Windows.h>
#include <iostream>
#include <string>
using namespace std;
int main()
{
SetConsoleCP(1251);
SetConsoleOutputCP(1251);
cout << "\n16. Выводим таблицу с заливкой \n";
for (int y = 1; y <= 10; y++)
{
for (int x = 1;x <= 10;x++)
{
if(x>=10-y+1)
cout << 1;
else
cout << 0;
cout << " ";
}
cout << "\n";
}
system("pause");
return 0;
}
Решение к задаче 17.
#include "stdafx.h"
#include <Windows.h>
#include <iostream>
#include <string>
using namespace std;
int main()
{
SetConsoleCP(1251);
SetConsoleOutputCP(1251);
cout << "\n17. Выводим таблицу с заливкой \n";
for (int y = 1; y <= 10; y++)
{
for (int x = 1;x <= 10;x++)
{
if ( (x >= 10 - y + 1 && x<=y) || (x <= 10 - y + 1 && x>=y))
cout << 1;
else
cout << 0;
cout << " ";
}
cout << "\n";
}
system("pause");
return 0;
}
Решение к задаче 18.
#include "stdafx.h"
#include <Windows.h>
#include <iostream>
#include <string>
using namespace std;
int main()
{
SetConsoleCP(1251);
SetConsoleOutputCP(1251);
cout << "\n18. Выводим таблицу с заливкой \n";
for (int y = 1; y <= 10; y++)
{
for (int x = 1;x <= 10;x++)
{
if ( y >= 10 - x + 1 && y<=x)
cout << 1;
else
cout << 0;
cout << " ";
}
cout << "\n";
}
system("pause");
return 0;
}
Решение к задаче 19.
#include "stdafx.h"
#include <Windows.h>
#include <iostream>
#include <string>
using namespace std;
int main()
{
SetConsoleCP(1251);
SetConsoleOutputCP(1251);
cout << "\n19. Выводим таблицу с заливкой \n";
for (int y = 1; y <= 10; y++)
{
for (int x = 1;x <= 10;x++)
{
if ( x >= 10 - y + 1 && x<=y)
cout << 1;
else
cout << 0;
cout << " ";
}
cout << "\n";
}
system("pause");
return 0;
}
Решение к задаче 20.
#include "stdafx.h"
#include <Windows.h>
#include <iostream>
#include <string>
using namespace std;
int main()
{
SetConsoleCP(1251);
SetConsoleOutputCP(1251);
cout << "\n20. Выводим таблицу с заливкой \n";
for (int y = 1; y <= 10; y++)
{
for (int x = 1;x <= 10;x++)
{
if ( y <= 10 - x + 1 && y>=x)
cout << 1;
else
cout << 0;
cout << " ";
}
cout << "\n";
}
system("pause");
return 0;
}
Решение к задаче 21.
#include "stdafx.h"
#include <Windows.h>
#include <iostream>
#include <string>
using namespace std;
int main()
{
SetConsoleCP(1251);
SetConsoleOutputCP(1251);
cout << "\n21. Выводим таблицу с заливкой \n";
for (int y = 1; y <= 10; y++)
{
for (int x = 1;x <= 10;x++)
{
if (x <= 10 - y + 1 && x>=y)
cout << 1;
else
cout << 0;
cout << " ";
}
cout << "\n";
}
system("pause");
return 0;
}
Решение к задаче 22.
#include "stdafx.h"
#include <Windows.h>
#include <iostream>
#include <string>
using namespace std;
int main()
{
SetConsoleCP(1251);
SetConsoleOutputCP(1251);
cout << "\n22. Выводим таблицу с заливкой \n";
for (int y = 1; y <= 10; y++)
{
for (int x = 1;x <= 10;x++)
{
if ((x <10 - y + 1 && x>y) || (x > 10 - y + 1 && x < y))
cout << 0;
else
cout << 1;
cout << " ";
}
cout << "\n";
}
system("pause");
return 0;
}
Решение к задаче 23.
#include "stdafx.h"
#include <Windows.h>
#include <iostream>
#include <string>
using namespace std;
int main()
{
SetConsoleCP(1251);
SetConsoleOutputCP(1251);
cout << "\n23. Выводим таблицу с заливкой \n";
for (int y = 1; y <= 10; y++)
{
for (int x = 1;x <= 10;x++)
{
if ( (x ==3 && y>2 && y<9) || (x == 8 && y>2 && y<9) || (y == 3 && x>2 && x<9) || (y == 8 && x>2 && x<9) || x==1 || y==1 || x==10 || y==10)
cout << 1;
else
cout << 0;
cout << " ";
}
cout << "\n";
}
system("pause");
return 0;
}