Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
programming-in-cxx-2024
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sdlbio-courses
programming-in-cxx-2024
Commits
7b55ede0
Commit
7b55ede0
authored
May 16, 2024
by
Sandipan Mohanty
Browse files
Options
Downloads
Patches
Plain Diff
Adjust some examples in chapter 6
parent
e7824291
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
chapter_06/examples/example_text.txt
+23
-0
23 additions, 0 deletions
chapter_06/examples/example_text.txt
chapter_06/examples/word_count.cc
+3
-6
3 additions, 6 deletions
chapter_06/examples/word_count.cc
chapter_06/examples/word_count_23.cc
+29
-0
29 additions, 0 deletions
chapter_06/examples/word_count_23.cc
with
55 additions
and
6 deletions
chapter_06/examples/example_text.txt
0 → 100644
+
23
−
0
View file @
7b55ede0
A solar flare is a relatively intense, localized emission of
electromagnetic radiation in the Sun's atmosphere. Flares
occur in active regions and are often, but not always,
accompanied by coronal mass ejections, solar particle events,
and other eruptive solar phenomena. The occurrence of solar
flares varies with the 11-year solar cycle.
Solar flares are thought to occur when stored magnetic energy
in the Sun's atmosphere accelerates charged particles in the
surrounding plasma. This results in the emission of
electromagnetic radiation across the electromagnetic spectrum.
The extreme ultraviolet and x-ray radiation from solar flares
is absorbed by the daylight side of Earth's upper atmosphere,
in particular the ionosphere, and does not reach the surface.
This absorption can temporarily increase the ionization of
the ionosphere which may interfere with short-wave radio
communication. The prediction of solar flares is an active
area of research.
Flares also occur on other stars, where the term stellar
flare applies.
This diff is collapsed.
Click to expand it.
chapter_06/examples/word_count.cc
+
3
−
6
View file @
7b55ede0
#include
<fstream>
#include
<fstream>
#include
<iomanip>
#include
<print>
#include
<iostream>
#include
<map>
#include
<map>
#include
<string>
#include
<string>
...
@@ -14,8 +13,6 @@ auto main(int argc, char* argv[]) -> int
...
@@ -14,8 +13,6 @@ auto main(int argc, char* argv[]) -> int
freq
[
s
]
++
;
freq
[
s
]
++
;
for
(
auto
&&
[
word
,
count
]
:
freq
)
for
(
auto
&&
[
word
,
count
]
:
freq
)
std
::
cout
<<
std
::
setw
(
12
)
<<
word
std
::
print
(
"{:20} :{:12}
\n
"
,
<<
std
::
setw
(
4
)
<<
':'
word
,
count
);
<<
std
::
setw
(
12
)
<<
count
<<
"
\n
"
;
}
}
This diff is collapsed.
Click to expand it.
chapter_06/examples/word_count_23.cc
0 → 100644
+
29
−
0
View file @
7b55ede0
#include
<fstream>
#include
<format>
#include
<ranges>
#include
<print>
#include
<map>
#include
<string>
namespace
sr
=
std
::
ranges
;
namespace
sv
=
sr
::
views
;
auto
main
(
int
argc
,
char
*
argv
[])
->
int
{
std
::
ifstream
fin
(
argv
[
1
]);
std
::
map
<
std
::
string
,
unsigned
>
freq
;
std
::
string
s
;
auto
non_alphabetic
=
[](
auto
c
)
{
return
not
isalpha
(
c
);
};
while
(
fin
>>
s
)
{
auto
s2
=
s
|
sv
::
drop_while
(
non_alphabetic
)
|
sv
::
reverse
|
sv
::
drop_while
(
non_alphabetic
)
|
sv
::
reverse
|
sr
::
to
<
std
::
string
>
();
freq
[
s2
]
++
;
}
for
(
auto
&&
[
word
,
count
]
:
freq
)
std
::
print
(
"{:20} :{:12}
\n
"
,
word
,
count
);
}
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