-
Notifications
You must be signed in to change notification settings - Fork 0
/
process.c
105 lines (65 loc) · 2 KB
/
process.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include <stdio.h>
#include "Typedef.h"
#include <getopt.h>
#include <stdlib.h>
void findAndSwapRelease()
{
int max_element=0, min_element=0, i, tmp;
for(i=0; i<n; i++)
{
if (arr[n-i-1][i]<arr[n-min_element-1][min_element])
min_element=i;
}
for(i=0; i<n; i++)
{
if (arr[n-i-1][i]>=arr[n-max_element-1][max_element])
max_element=i;
}
tmp=arr[n-min_element-1][min_element];
arr[n-min_element-1][min_element]=arr[n-max_element-1][max_element];
arr[n-max_element-1][max_element]=tmp;
}
void findAndSwapDebug()
{
int max_element=0, min_element=0, i, tmp;
for(i=0; i<n; i++)
{
if (arr[n-i-1][i]<arr[n-min_element-1][min_element])
min_element=i;
printf("min element is %d on position [%d][%d]\n",arr[n-min_element-1][min_element], n-min_element-1, min_element);
}
printf("\n\n");
for(i=0; i<n; i++)
{
if (arr[n-i-1][i]>=arr[n-max_element-1][max_element])
max_element=i;
printf("max element is %d on position [%d][%d]\n",arr[n-max_element-1][max_element], n-max_element-1, max_element);
}
printf("\n\n");
printf("Success!!!!! \nFinal results:\nmin element is %d on position [%d][%d]\nmax element is %d on position [%d][%d]",arr[n-min_element-1][min_element], n-min_element-1, min_element,arr[n-max_element-1][max_element], n-max_element-1, max_element);
tmp=arr[n-min_element-1][min_element];
arr[n-min_element-1][min_element]=arr[n-max_element-1][max_element];
arr[n-max_element-1][max_element]=tmp;
printf("\nResult:\n");
}
char verbose_flag(int argc,char*argv[])
{
char choise='r';
char options;
while((options = getopt(argc,argv, "drn:"))!=-1)
{
switch(options)
{
case'r':
choise = 'r';
break;
case'd':
choise = 'd';
break;
case'n':
n = atoi(optarg);
break;
}
}
return choise;
}