Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
программы С++2.docx
Скачиваний:
0
Добавлен:
01.07.2025
Размер:
107 Кб
Скачать

Int main(){

setlocale(LC_ALL,"Rus");

int a[HB];

int k;

int ok;

printf("Проверка, упорядочен ли массив\n по возрастанию\nВведите массив (%iцелых чисел",HB);

printf(" в одной строке ) и нажмите <Enter>\n");

for (k=0;k<HB;k++)

scanf("%i",&a[k]);

k=0;

ok=1;

do{

if (a[k]>a[k+1])

ok=0;

k++;}

while(k<HB-1 && ok);

printf("элементы Массива");

if (!ok)

printf(" не");

printf(" упорядочены по возрастанию\nДля завершения нажмите <Enter>");

getch();

return 0;

}

// Функция возвращающая сумму двух целых.cpp: определяет точку входа для консольного приложения.

#include "stdafx.h"

#include <iostream>

#include <conio.h>

#include <clocale>

#include <stdio.h>

using namespace std;

int sum (int a,int b);

Int main(){

setlocale(LC_ALL,"Rus");

int a=2, b=3, c,d;

c=sum(a,b);

cout<<"\nВедите d=";cin>>d;

cout<<"\nРезультат суммы c и d:"<<sum(a,b);

getch();

return 0;}

int sum(int a,int b){

return (a+b);}

// программа 1.cpp: определяет точку входа для консольного приложения.

//

#include "stdafx.h"

#include <iostream>

#include <conio.h>

using std::cout;

using std::cin;

void f(int a){

int m=0;

cout<<"m n p\n";

while(a--){

static int n=0;

int p=0;

cout<<n++<<' '<<m++<<' '<<p++<<'\n';}

}

int main() {f(3); f(2);

getch ();

return 0;}

// программа 2.cpp: определяет точку входа для консольного приложения.

#include "stdafx.h"

#include <iostream>

#include <conio.h>

using std::cout;

using std::cin;

void f(int i,int*j,int&k);

Int main (){

int i=1 ,j=2, k=3;

cout<<"i j k\n";

cout<<i<<' '<<j<<' '<<k<<'\n';

f(i,&j,k);

cout<<i<<' '<<j<<' '<<k;

getch ();

return 0;}

void f(int i,int*j,int&k){

i++;(*j)++;k++;}

// программа 3.cpp: определяет точку входа для консольного приложения.

//

#include "stdafx.h"

#include <iostream>

#include <conio.h>

#include <clocale>

using std::cout;

int sum(const int* mas,const int n);

int const n=10;

Int main(){

setlocale(LC_ALL,"Rus");

int marks [n]={3,4,5,4,4};

cout<<"\nСумма элементов массива:"<<sum(marks,n);

getch ();

return 0;}

int sum (const int* mas, const int n){

int s=0;

for (int i=0; i<n; i++)s+=mas[i];

return s;}

// программа 4.cpp: определяет точку входа для консольного приложения.

#include "stdafx.h"

#include <iostream>

#include <conio.h>

#include <clocale>

#include <stdlib.h>

int sum(const int *a, const int nstr, const int nstb);

Int main(){

setlocale(LC_ALL,"Rus");

int b[2][2]={{2,2},{4,3}};

int *a,i,j,nstr,nstb;

printf("Введите количество строк и столбцов:\n");

scanf("%d%d",&nstr,&nstb);

a=(int*)malloc(nstr*nstb*sizeof(int));

for(i=0;i<nstr;i++)

for(j=0;j<nstb;j++)scanf("%d",&a[i*nstb+j]);

printf("Сумма элементов a:%d\n",sum(a,nstr,nstb));

getch ();

return 0; }

int sum(const int *a,const int nstr, const int nstb){

int i,j,s=0;

for(i=0;i<nstb;i++)

for(j=0;j<nstr;j++)s+=a[i*nstb];

return s;}

// Динамичесткая структура данных 1.cpp: определяет точку входа для консольного приложения.

#include "stdafx.h"

#include <iostream>

#include <conio.h>

using std ::cout;

struct Node{

int d;

Node *p;};

Node * first(int d);

void push (Node **top, int d);

int pop (Node **top);

//----------