Sub AppendExt()
Dim WB As Workbook
Dim WS As Worksheet
Dim Ri As Integer
Dim Rj As Integer
Dim Ci As Integer
Dim Cj As Integer
Set WB = Excel.ActiveWorkbook
Set WS = WB.Worksheets("list1")
' Диапазон ячеек для замены
' Начальная строка
Ri = 1
' Конечная строка
Rj = 4
' Начальный столбец
Ci = 1
' Конечный столбец
Cj = 2
For C = Ci To Cj
For R = Ri To Rj
If Not IsEmpty(WS.Cells(R, C)) Then
WS.Cells(R, C).Value = WS.Cells(R, C).Value & ".jpg"
End If
Next R
Next C
End Sub
Sub AppendExt()
Dim WB As Workbook
Dim WS As Worksheet
Set WB = Excel.ActiveWorkbook
Set WS = WB.Worksheets("list1")
For Each HL In WS.Hyperlinks
HL.Address = HL.Address & ".jpg"
Next
End Sub
using System;
using System.Collections.Generic;
namespace matrix
{
internal class Program
{
private static void Main(string[] args)
{
if (args.Length > 0)
return;
string[] matrix =
{
"1b2ba",
"b====",
"ccb++",
"ccab+"
};
HorizontalLeftToRight(matrix);
VerticalTopToBottom(matrix);
DiagonalUp(matrix);
DiagonalDown(matrix);
Console.ReadLine();
}
private static void HorizontalLeftToRight(IReadOnlyList<string> matrix)
{
for (var row = 0; row < matrix.Count; row++)
{
var count = 0;
for (var col = 0; col < matrix[0].Length; col++)
{
count++;
try
{
if (matrix[row][col].Equals(matrix[row][col + 1])) continue;
if (count > 1)
Console.WriteLine("{0} [{1}, {2}] \'{3}\' {4}", Convert.ToChar(26), row, col - count + 1, matrix[row][col], count);
}
catch (IndexOutOfRangeException)
{
if (count > 1)
Console.WriteLine("{0} [{1}, {2}] \'{3}\' {4}", Convert.ToChar(26), row, col - count + 1, matrix[row][col], count);
}
count = 0;
}
}
}
private static void VerticalTopToBottom(IReadOnlyList<string> matrix)
{
for (var col = 0; col < matrix[0].Length; col++)
{
var count = 0;
for (var row = 0; row < matrix.Count; row++)
{
count++;
try
{
if (matrix[row][col].Equals(matrix[row + 1][col])) continue;
if (count > 1)
Console.WriteLine("{0} [{1}, {2}] \'{3}\' {4}", Convert.ToChar(25), row - count + 1, col, matrix[row][col], count);
}
catch (ArgumentOutOfRangeException)
{
if (count > 1)
Console.WriteLine("{0} [{1}, {2}] \'{3}\' {4}", Convert.ToChar(25), row - count + 1, col, matrix[row][col], count);
}
count = 0;
}
}
}
private static void DiagonalUp(IReadOnlyList<string> matrix)
{
for (var row = 1; row < matrix.Count; row++)
{
var r = row;
var count = 0;
for (var col = 0; col < matrix[0].Length; col++)
{
count++;
try
{
if (matrix[r][col].Equals(matrix[r - 1][col + 1])) continue;
if (count > 1)
Console.WriteLine("{0} [{1}, {2}] \'{3}\' {4}", Convert.ToChar(47), r + count - 1, col - count + 1, matrix[r][col], count);
}
catch (IndexOutOfRangeException)
{
if (count > 1)
Console.WriteLine("{0} [{1}, {2}] \'{3}\' {4}", Convert.ToChar(47), r + count - 1, col - count + 1, matrix[r][col], count);
}
catch (ArgumentOutOfRangeException)
{
if (count > 1)
Console.WriteLine("{0} [{1}, {2}] \'{3}\' {4}", Convert.ToChar(47), r + count - 1, col - count + 1, matrix[r][col], count);
}
finally
{
r--;
}
count = 0;
}
}
for (var col = 1; col < matrix[0].Length; col++)
{
var c = col;
var count = 0;
for (var row = matrix.Count - 1; row > -1; row--)
{
count++;
try
{
if (matrix[row][c].Equals(matrix[row - 1][c + 1])) continue;
if (count > 1)
Console.WriteLine("{0} [{1}, {2}] \'{3}\' {4}", Convert.ToChar(47), row + count - 1, c - count + 1, matrix[row][c], count);
}
catch (IndexOutOfRangeException)
{
if (count > 1)
Console.WriteLine("{0} [{1}, {2}] \'{3}\' {4}", Convert.ToChar(47), row + count - 1, c - count + 1, matrix[row][c], count);
}
catch (ArgumentOutOfRangeException)
{
if (count > 1)
Console.WriteLine("{0} [{1}, {2}] \'{3}\' {4}", Convert.ToChar(47), row + count - 1, c - count + 1, matrix[row][c], count);
}
finally
{
c++;
}
count = 0;
}
}
}
private static void DiagonalDown(IReadOnlyList<string> matrix)
{
for (var col = matrix[0].Length - 2; col > -1; col--)
{
var c = col;
var count = 0;
for (var row = 0; row < matrix.Count; row++)
{
count++;
try
{
if (matrix[row][c].Equals(matrix[row + 1][c + 1])) continue;
if (count > 1)
Console.WriteLine("{0} [{1}, {2}] \'{3}\' {4}", Convert.ToChar(92), row - count + 1, c - count + 1, matrix[row][c], count);
}
catch (IndexOutOfRangeException)
{
if (count > 1)
Console.WriteLine("{0} [{1}, {2}] \'{3}\' {4}", Convert.ToChar(92), row - count + 1, c - count + 1, matrix[row][c], count);
}
catch (ArgumentOutOfRangeException)
{
if (count > 1)
Console.WriteLine("{0} [{1}, {2}] \'{3}\' {4}", Convert.ToChar(92), row - count + 1, c - count + 1, matrix[row][c], count);
}
finally
{
c++;
}
count = 0;
}
}
for (var row = 1; row < matrix.Count; row++)
{
var r = row;
var count = 0;
for (var col = 0; col < matrix[0].Length; col++)
{
count++;
try
{
if (matrix[r][col].Equals(matrix[r + 1][col + 1])) continue;
if (count > 1)
Console.WriteLine("{0} [{1}, {2}] \'{3}\' {4}", Convert.ToChar(92), r - count + 1, col - count + 1, matrix[r][col], count);
}
catch (IndexOutOfRangeException)
{
if (count > 1)
Console.WriteLine("{0} [{1}, {2}] \'{3}\' {4}", Convert.ToChar(92), r - count + 1, col - count + 1, matrix[r][col], count);
}
catch (ArgumentOutOfRangeException)
{
if (count > 1)
Console.WriteLine("{0} [{1}, {2}] \'{3}\' {4}", Convert.ToChar(92), r - count + 1, col - count + 1, matrix[r][col], count);
}
finally
{
r++;
}
count = 0;
}
}
}
}
}
program MatrixArea;
const N = 5;
var
matrix: array[1..N, 1..N] of integer;
i, j: integer;
edge: integer;
sum: integer;
min: integer;
begin
randomize;
{заполняем массив}
for i := 1 to N do
for j := 1 to N do
matrix[i][j] := Random(50);
{печатаем массив}
for i := 1 to N do
begin
for j := 1 to N do
Write(matrix[i][j]:3);
WriteLn();
end;
WriteLn();
{печатаем заштрихованную область массива}
{находим минимальный элемент и сумму всех элементов в заштрихованной области}
edge := N;
min := matrix[1][edge];
sum := 0;
for i := 1 to N do
begin
for j := 1 to N do
begin
if (j >= edge) then
begin
sum := sum + matrix[i][j];
if (min > matrix[i][j]) then
min := matrix[i][j];
Write(matrix[i][j]:3);
end
else
Write('..':3);
end;
if (i < N div 2 + 1) then
edge := edge - 1
else
edge := edge + 1;
WriteLn();
end;
WriteLn();
WriteLn('Сумма: ', sum);
WriteLn('Минимальный элемент: ', min);
end.
=ПРАВСИМВ(A1;2)&"-"&ПСТР(A1;4;2)&"-"&ЛЕВСИМВ(A1;2)
Sub ReverseString()
Dim WB As Workbook
Dim WS As Worksheet
Dim R As Integer
Set WB = Excel.ActiveWorkbook
Set WS = WB.Worksheets("reverse")
' Меняется столбец A1
R = 1
While (WS.Cells(R, 1).Value <> "")
s = Split(WS.Cells(R, 1).Value, "-")
WS.Cells(R, 1).Value = Join(Array(s(2), s(1), s(0)), "-")
R = R + 1
Wend
End Sub
program max_element;
var
matrix: array[0..4, 0..4] of integer;
i, j: integer;
max: integer;
begin
Randomize;
// Заполнение матрицы
for i := 0 to 4 do
begin
for j := 0 to 4 do
matrix[i][j] := Random(10, 99);
WriteLn(matrix[i]);
end;
i := 0;
j := 0;
max := matrix[i][j];
for j := 0 to 4 do
for i := j to 4 do
if max < matrix[i][j] then
max := matrix[i][j];
WriteLn(max);
end.
Dim WB as Workbook
Dim WS as Worksheet
Dim i as Integer
Set WB = Excel.ActiveWorkbook
Set WS = WB.Worksheets("Лист1")
i = 1
For b = 2 To 8 Step 2
For c = 4 To 10 Step 2
For d = 10 To 50 Step 10
' Выводит числа в столбик '
WS.Cells(i, 1).Value = 10 + b * c * d
i = i + 1
Next d
Next c
Next b
$arr = [
['Пн', '08:00 - 20:00'],
['Вт', '08:00 - 20:00'],
['Ср', '08:00 - 20:00'],
['Чт', '08:00 - 20:00'],
['Пт', '08:00 - 20:00'],
['Сб', '08:00 - 18:00'],
['Вс', '10:00 - 15:00'],
];
$res = "";
$i = 0;
do {
$j = $i + 1;
do {
if ($arr[$i][1] <> $arr[$j][1]) {
break;
}
$j++;
} while ($j < count($arr));
if (strlen($res) > 0) {
$res .= ", ";
}
if ($i == $j - 1) {
$res .= $arr[$i][0] . ": " . $arr[$i][1];
}
else {
$res .= $arr[$i][0] . '-' . $arr[$j - 1][0] . ': ' . $arr[$i][1];
}
$i = $j;
} while ($i < count($arr));
echo $res;
Sub ToDo()
Dim WB As Workbook
Dim WS_Task As Worksheet
Dim WS_Action As Worksheet
Dim TaskRowIndex As Long
Dim ActionRowIndex As Long
Set WB = Excel.ActiveWorkbook
Set WS_Task = WB.Worksheets("Задачи")
Set WS_Action = WB.Worksheets("Действия")
For TaskRowIndex = WS_Task.Rows.Count To 2 Step -1
If WS_Task.Cells(TaskRowIndex, 1) <> "" Then
Exit For
End If
Next TaskRowIndex
For ActionRowIndex = WS_Action.Rows.Count To 2 Step -1
If WS_Action.Cells(ActionRowIndex, 1) <> "" Then
Exit For
End If
Next ActionRowIndex
For TaskRow = TaskRowIndex To 1 Step -1
TaskNumber = WS_Task.Cells(TaskRow, 1)
If TaskNumber <> "" And IsNumeric(TaskNumber) Then
TaskRowShift = TaskRow + 1
For ActionRow = ActionRowIndex To 2 Step -1
If WS_Action.Cells(ActionRow, 2) = TaskNumber Then
WS_Task.Rows(Int(TaskRowShift)).Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
WS_Task.Cells(TaskRowShift, 3) = WS_Action.Cells(ActionRow, 1)
WS_Task.Cells(TaskRowShift, 4) = WS_Action.Cells(ActionRow, 2)
WS_Task.Cells(TaskRowShift, 5) = WS_Action.Cells(ActionRow, 3)
End If
Next ActionRow
End If
Next TaskRow
End Sub
Sub duplicate()
Dim StrIn As String
Dim StrOut As String
Dim Symbol As String
Dim Twice As Boolean
StrIn = "835*23*2"
Symbol = "2"
StrOut = ""
If InStr(StrIn, Symbol) > 0 Then
Twice = True
Else
Twice = False
End If
For i = 1 To Len(StrIn)
Char = Mid(StrIn, i, 1)
Select Case Char
Case Symbol
StrOut = StrOut & Char
Case "*"
StrOut = StrOut
Case Else
StrOut = StrOut & Char
If Twice Then
StrOut = StrOut & Char
End If
End Select
Next i
MsgBox (StrOut)
End Sub