Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PPC-2025
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Husam Ahmad
PPC-2025
Commits
fd1f905f
Commit
fd1f905f
authored
5 days ago
by
Husam-Ahmad
Browse files
Options
Downloads
Patches
Plain Diff
perfect
parent
6ac72b42
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
DU1/.vscode/settings.json
+55
-0
55 additions, 0 deletions
DU1/.vscode/settings.json
DU1/main
+0
-0
0 additions, 0 deletions
DU1/main
DU1/main.cpp
+89
-18
89 additions, 18 deletions
DU1/main.cpp
with
144 additions
and
18 deletions
DU1/.vscode/settings.json
0 → 100644
+
55
−
0
View file @
fd1f905f
{
"files.associations"
:
{
"iomanip"
:
"cpp"
,
"array"
:
"cpp"
,
"atomic"
:
"cpp"
,
"bit"
:
"cpp"
,
"*.tcc"
:
"cpp"
,
"bitset"
:
"cpp"
,
"cctype"
:
"cpp"
,
"clocale"
:
"cpp"
,
"cmath"
:
"cpp"
,
"compare"
:
"cpp"
,
"concepts"
:
"cpp"
,
"cstdarg"
:
"cpp"
,
"cstddef"
:
"cpp"
,
"cstdint"
:
"cpp"
,
"cstdio"
:
"cpp"
,
"cstdlib"
:
"cpp"
,
"cstring"
:
"cpp"
,
"ctime"
:
"cpp"
,
"cwchar"
:
"cpp"
,
"cwctype"
:
"cpp"
,
"deque"
:
"cpp"
,
"map"
:
"cpp"
,
"string"
:
"cpp"
,
"unordered_map"
:
"cpp"
,
"vector"
:
"cpp"
,
"exception"
:
"cpp"
,
"algorithm"
:
"cpp"
,
"functional"
:
"cpp"
,
"iterator"
:
"cpp"
,
"memory"
:
"cpp"
,
"memory_resource"
:
"cpp"
,
"numeric"
:
"cpp"
,
"random"
:
"cpp"
,
"regex"
:
"cpp"
,
"string_view"
:
"cpp"
,
"system_error"
:
"cpp"
,
"tuple"
:
"cpp"
,
"type_traits"
:
"cpp"
,
"utility"
:
"cpp"
,
"initializer_list"
:
"cpp"
,
"iosfwd"
:
"cpp"
,
"iostream"
:
"cpp"
,
"istream"
:
"cpp"
,
"limits"
:
"cpp"
,
"new"
:
"cpp"
,
"numbers"
:
"cpp"
,
"ostream"
:
"cpp"
,
"sstream"
:
"cpp"
,
"stdexcept"
:
"cpp"
,
"streambuf"
:
"cpp"
,
"typeinfo"
:
"cpp"
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
DU1/main
deleted
100755 → 0
+
0
−
0
View file @
6ac72b42
File deleted
This diff is collapsed.
Click to expand it.
DU1/main.cpp
+
89
−
18
View file @
fd1f905f
...
...
@@ -6,6 +6,11 @@ int config_min = -99;
int
config_max
=
100
;
int
config_width
=
3
;
std
::
string
config_align
=
"left"
;
int
config_stretch
=
0
;
bool
isstretchprovided
=
false
;
int
config_header
=
1
;
bool
isheaderprovided
=
false
;
std
::
vector
<
std
::
vector
<
std
::
string
>>
table
;
// data from the table
...
...
@@ -51,8 +56,12 @@ void printconfig()
{
std
::
cout
<<
"config.min="
<<
config_min
<<
std
::
endl
;
std
::
cout
<<
"config.max="
<<
config_max
<<
std
::
endl
;
std
::
cout
<<
"config.width="
<<
config_width
<<
std
::
endl
;
std
::
cout
<<
"config.width="
<<
config_width
+
config_stretch
<<
std
::
endl
;
std
::
cout
<<
"config.align="
<<
config_align
<<
std
::
endl
;
if
(
isheaderprovided
)
std
::
cout
<<
"config.header="
<<
config_header
<<
std
::
endl
;
if
(
isstretchprovided
)
std
::
cout
<<
"config.stretch="
<<
config_stretch
<<
std
::
endl
;
std
::
cout
<<
"
\n
"
;
}
...
...
@@ -85,6 +94,8 @@ void dothesum()
}
}
row
[
i
]
=
std
::
to_string
(
sum
);
if
((
static_cast
<
int
>
(
row
[
i
].
length
())
>
config_width
)
&&
!
isstretchprovided
)
errorhere
(
"Cell is too short"
,
103
);
}
}
}
...
...
@@ -98,24 +109,76 @@ void printthedamntable()
if
(
row
.
size
()
>
maxcols
)
maxcols
=
row
.
size
();
}
std
::
string
border
=
"+-"
+
std
::
string
(
config_width
,
'-'
)
+
"-"
;
for
(
size_t
i
=
0
;
i
<
maxcols
;
i
++
)
border
+=
"+-"
+
std
::
string
(
config_width
,
'-'
)
+
"-"
;
std
::
string
border
=
"+-"
+
std
::
string
(
config_width
+
config_stretch
,
'-'
)
+
"-"
;
if
(
config_header
==
1
)
for
(
size_t
i
=
0
;
i
<
maxcols
;
i
++
)
border
+=
"+-"
+
std
::
string
(
config_width
+
config_stretch
,
'-'
)
+
"-"
;
else
if
(
config_header
==
0
)
for
(
size_t
i
=
1
;
i
<
maxcols
;
i
++
)
border
+=
"+-"
+
std
::
string
(
config_width
+
config_stretch
,
'-'
)
+
"-"
;
border
+=
"+"
;
if
(
config_header
==
1
)
{
std
::
cout
<<
border
<<
std
::
endl
;
std
::
cout
<<
"| "
<<
std
::
string
(
config_width
+
config_stretch
,
' '
)
<<
" |"
;
for
(
size_t
i
=
0
;
i
<
maxcols
;
i
++
)
std
::
cout
<<
" "
<<
std
::
setw
(
config_width
+
config_stretch
)
<<
(
config_align
==
"left"
?
std
::
left
:
std
::
right
)
<<
static_cast
<
char
>
(
'A'
+
i
)
<<
" |"
;
std
::
cout
<<
std
::
endl
;
}
std
::
cout
<<
border
<<
std
::
endl
;
std
::
cout
<<
"| "
<<
std
::
string
(
config_width
,
'-'
)
<<
" |"
;
for
(
size_t
i
=
0
;
i
<
maxcols
;
i
++
)
std
::
cout
<<
" "
<<
std
::
setw
(
config_width
)
<<
(
config_align
==
"left"
?
std
::
left
:
std
::
right
)
<<
static_cast
<
char
>
(
'A'
+
i
)
<<
" |"
;
std
::
cout
<<
std
::
endl
<<
border
<<
std
::
endl
;
for
(
size_t
i
=
0
;
i
<
table
.
size
();
i
++
)
if
(
config_header
==
1
)
{
for
(
size_t
i
=
0
;
i
<
table
.
size
();
i
++
)
{
std
::
cout
<<
"| "
<<
std
::
setw
(
config_width
+
config_stretch
);
std
::
cout
<<
(
config_align
==
"left"
?
std
::
left
:
std
::
right
)
<<
i
+
1
;
std
::
cout
<<
" |"
;
for
(
size_t
j
=
0
;
j
<
maxcols
;
j
++
)
{
if
(((
size_t
)(
config_width
+
config_stretch
)
>=
table
[
i
][
j
].
size
())
||
table
[
i
][
j
].
size
()
>
10
)
{
std
::
cout
<<
" "
<<
std
::
setw
(
config_width
+
config_stretch
)
<<
(
config_align
==
"left"
?
std
::
left
:
std
::
right
);
std
::
cout
<<
(
j
<
table
[
i
].
size
()
?
table
[
i
][
j
]
:
""
);
}
else
{
std
::
cout
<<
" "
<<
(
config_align
==
"left"
?
std
::
left
:
std
::
right
);
for
(
int
l
=
0
;
(
config_width
+
config_stretch
)
>
l
;
l
++
)
std
::
cout
<<
"#"
;
}
std
::
cout
<<
" |"
;
}
std
::
cout
<<
std
::
endl
<<
border
<<
std
::
endl
;
}
}
if
(
config_header
==
0
)
{
std
::
cout
<<
"| "
<<
std
::
setw
(
config_width
)
<<
(
config_align
==
"left"
?
std
::
left
:
std
::
right
)
<<
i
+
1
<<
" |"
;
for
(
size_t
j
=
0
;
j
<
maxcols
;
j
++
)
std
::
cout
<<
" "
<<
std
::
setw
(
config_width
)
<<
(
config_align
==
"left"
?
std
::
left
:
std
::
right
)
<<
(
j
<
table
[
i
].
size
()
?
table
[
i
][
j
]
:
""
)
<<
" |"
;
std
::
cout
<<
std
::
endl
<<
border
<<
std
::
endl
;
for
(
size_t
i
=
0
;
i
<
table
.
size
();
i
++
)
{
std
::
cout
<<
"|"
;
for
(
size_t
j
=
0
;
j
<
maxcols
;
j
++
)
{
if
(((
size_t
)(
config_width
+
config_stretch
)
>=
table
[
i
][
j
].
size
())
||
table
[
i
][
j
].
size
()
>
10
)
{
std
::
cout
<<
" "
<<
std
::
setw
(
config_width
+
config_stretch
)
<<
(
config_align
==
"left"
?
std
::
left
:
std
::
right
);
std
::
cout
<<
(
j
<
table
[
i
].
size
()
?
table
[
i
][
j
]
:
""
);
}
else
{
std
::
cout
<<
" "
<<
(
config_align
==
"left"
?
std
::
left
:
std
::
right
);
for
(
int
l
=
0
;
(
config_width
+
config_stretch
)
>
l
;
l
++
)
std
::
cout
<<
"#"
;
}
std
::
cout
<<
" |"
;
}
std
::
cout
<<
std
::
endl
<<
border
<<
std
::
endl
;
}
}
}
// << std::setw(config_width + config_stretch)
config_t
configureit
(
std
::
string
init
)
{
config_t
config
;
...
...
@@ -185,7 +248,6 @@ void draw_line(int columns, int width)
int
main
()
{
std
::
string
init
,
svalue
,
cell
;
int
longest
;
while
(
std
::
getline
(
std
::
cin
,
init
)
&&
init
!=
"="
)
{
...
...
@@ -204,6 +266,16 @@ int main()
}
else
if
(
config
.
type
==
"align"
)
config_align
=
config
.
value
;
else
if
(
config
.
type
==
"stretch"
)
{
config_stretch
=
std
::
stoi
(
config
.
value
);
isstretchprovided
=
true
;
}
else
if
(
config
.
type
==
"header"
)
{
config_header
=
std
::
stoi
(
config
.
value
);
isheaderprovided
=
true
;
}
}
else
errorhere
(
"Invalid configuration"
,
102
);
...
...
@@ -218,21 +290,20 @@ int main()
while
((
end
=
svalue
.
find
(
';'
,
start
))
!=
std
::
string
::
npos
)
{
cell
=
svalue
.
substr
(
start
,
end
-
start
);
if
(
static_cast
<
int
>
(
cell
.
length
())
>
config_width
)
errorhere
(
"Cell is too short"
,
100
);
start
=
1
+
end
;
row
.
push_back
(
svalue
.
empty
()
?
" "
:
cell
);
}
row
.
push_back
(
svalue
.
substr
(
start
));
// to add the last element
if
(
endswithsemicolon
)
row
.
push_back
(
" "
);
row
.
push_back
(
" "
);
table
.
push_back
(
row
);
}
if
(
isoutofrange
())
return
100
;
printconfig
();
dothesum
();
printconfig
();
printthedamntable
();
// printf("\n\n%d", (int)table[0][2].size());
}
// // -40;-50;-60;-70
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment