Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
muhega
/
iax0583
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
90085fc6
authored
Dec 05, 2017
by
muhega
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
586aff2c
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
145 additions
and
0 deletions
Homework2/main.c
Homework2/main.c
0 → 100644
View file @
90085fc6
#include <stdio.h>
#include <stdlib.h>
int
scan1
();
int
scan2
();
void
scan3
(
int
row
,
int
col
,
int
array
[
row
][
col
]);
void
printing1
(
int
row
,
int
col
,
int
array
[
row
][
col
]);
void
sum
(
int
row
,
int
col
,
int
array
[
row
][
col
],
int
total
[
col
]);
void
most
(
int
size
,
int
total
[
size
]);
int
main
()
{
int
rows
=
scan1
(),
cols
=
scan2
();
int
arr
[
rows
][
cols
],
tot
[
cols
];
scan3
(
rows
,
cols
,
arr
);
printf
(
"sales matrix
\n
"
);
printing1
(
rows
,
cols
,
arr
);
sum
(
rows
,
cols
,
arr
,
tot
);
most
(
cols
,
tot
);
return
0
;
}
int
scan1
()
{
int
row
,
br
=
5
;
printf
(
"please enter the number of product groups, PS: maximum 15
\n
"
);
while
(
br
>
0
)
{
scanf
(
"%d"
,
&
row
);
if
(
row
<=
15
&&
row
>
0
)
{
break
;
}
else
{
printf
(
"invalid number please enter again
\n
"
);
}
}
return
row
;
}
int
scan2
()
{
int
col
,
br
=
5
;
printf
(
"please enter the number of salesclerks, PS: maximum 15
\n
"
);
while
(
br
>
0
)
{
scanf
(
"%d"
,
&
col
);
if
(
col
<=
15
&&
col
>
0
)
{
break
;
}
else
{
printf
(
"invalid number please enter again
\n
"
);
}
}
return
col
;
}
void
scan3
(
int
row
,
int
col
,
int
array
[
row
][
col
])
{
int
i
,
j
;
for
(
j
=
0
;
j
<
col
;
j
++
)
{
for
(
i
=
0
;
i
<
row
;
i
++
)
{
printf
(
"enter number of products sold by clerk %d for product group %d
\n
"
,(
j
+
1
),(
i
+
1
));
scanf
(
"%d"
,
&
array
[
i
][
j
]);
}
}
return
;
}
void
printing1
(
int
row
,
int
col
,
int
array
[
row
][
col
])
{
int
nrow
=
row
+
1
,
ncol
=
col
+
1
,
i
,
j
;
for
(
i
=
0
;
i
<
nrow
;
i
++
)
{
if
(
i
==
0
)
{
for
(
j
=
0
;
j
<
ncol
;
j
++
)
{
if
(
j
==
0
)
{
printf
(
"
\t\t
"
);
}
else
{
printf
(
"C%02d
\t
"
,
j
);
}
}
}
else
{
for
(
j
=
0
;
j
<
ncol
;
j
++
)
{
if
(
j
==
0
)
{
printf
(
"PRODUCT%02d
\t
"
,
i
);
}
else
{
printf
(
"%3d
\t
"
,
array
[(
i
-
1
)][(
j
-
1
)]);
}
}
}
printf
(
"
\n
"
);
}
return
;
}
void
sum
(
int
row
,
int
col
,
int
array
[
row
][
col
],
int
total
[
col
])
{
int
i
,
j
,
ncol
=
col
+
1
;
for
(
j
=
0
;
j
<
col
;
j
++
)
{
total
[
j
]
=
0
;
for
(
i
=
0
;
i
<
row
;
i
++
)
{
total
[
j
]
+=
array
[
i
][
j
];
}
}
for
(
j
=
0
;
j
<
ncol
;
j
++
)
{
if
(
j
==
0
)
{
printf
(
" total
\t
"
);
}
else
{
printf
(
"%3d
\t
"
,
total
[(
j
-
1
)]);
}
}
return
;
}
void
most
(
int
size
,
int
total
[
size
])
{
int
i
,
big
=
total
[
0
],
index
=
0
;
for
(
i
=
0
;
i
<
size
;
i
++
)
{
if
(
total
[
i
]
>
big
)
{
big
=
total
[
i
];
index
=
i
+
1
;
}
}
printf
(
"
\n
most productive clerk: C%02d"
,
index
);
return
;
}
muhega
@muhega
commented
Dec 07, 2017
Master
just grade my code
just grade my code
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment