Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include <stdio.h>
- #include <iostream>
- const int n = 10;
- void max(int[]);
- void null(int*);
- void show(const int*);
- int main() {
- setlocale(0, "Russian");
- int array[n] = { 0,1,2,3,4,5,6,7,8,9 };
- show(array);
- max(array);
- show(array);
- null(array);
- show(array);
- system("pause");
- return 0;
- }
- void max(int a[]) {
- static int counter1 = 0;
- counter1++;
- printf("#function max is called %d time\n", counter1);
- int max = a[0];
- for (int i = 0; i < n; i++)
- if (a[i] > max) max = a[i];
- for (int i = 0; i < n; i++)
- a[i] = max;
- }
- void null(int *a) {
- static int counter2 = 0;
- counter2++;
- printf("#function null is called %d time\n", counter2);
- for (int i = 0; i < n; i++) {
- *a = 0;
- a++;
- }
- }
- void show(const int *a) {
- printf("array is{");
- for (int i = 0; i < n; i++) {
- printf(" %d,", *a);
- a++;
- }
- printf("}\n");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement