diff --git a/1.cpp b/1.cpp index 898198d..f3622b9 100644 --- a/1.cpp +++ b/1.cpp @@ -1,11 +1,18 @@ -// Разверните строку. Указатель reverse_string должен -// указывать на развернутую строку. - -char* string = "The string!"; - +#include +char* string="The string!";; int main() { char* reverse_string; - + reverse_string=new char[strlen(string)+1]; + int it(0); + for (int i=strlen(string)-1;i>=0;i--) + { + reverse_string[it]=string[i]; + it++; + } + reverse_string[it]='\0'; + std::cout< +#include const int c_kM = 5; typedef int Matrix[c_kM][c_kM]; int min_from_top_sector(Matrix& m) { + const int c_kM = 4; + typedef int Matrix[c_kM][c_kM]; + int min_from_top_sector(Matrix& m) + { + double min; + min=m[0][0]; + int indeks=(c_kM%2==0)?c_kM/2:c_kM/2+1; + for (int i=0;i>matrix[i][j]; + } std::cout << min_from_top_sector(matrix) << std::endl; return 0; diff --git a/3.cpp b/3.cpp index 169e055..74d40cb 100644 --- a/3.cpp +++ b/3.cpp @@ -1,8 +1,5 @@ // Напишите функцию Add(), которая создает новый -// объект List, инициализирует его входным значением -// value и добавляет его в конец списка l, полученного -// на вход. В функции main() создайте проинициализированный -// список, со значениями value равными: 1, 2, 3, 4 и 5. +// Напишите функцию Add(), которая создает новый объект List, инициализирует его входным значением value и добавляет его в конец списка l, полученного на вход. В функции main() создайте проинициализированный список, со значениями value равными: 1, 2, 3, 4 и 5. struct List { @@ -14,10 +11,26 @@ struct List // It should return pointer to the added List object. List* Add(List* l, int value) { - + List *newList=new List; + newList->value=value; + newList->next=NULL; + if(l) + { + while(l->next) + l=l->next; + + l->next=newList; + return l; + } + else + return(newList); } int main(int argc, char* argv[]) { + List *_lst=new List; + _lst->value=1; + for(int i=1;i<5;i++) + _lst=Add(_lst,i); return 0; -} \ No newline at end of file +}