Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
李楚霏
/
cppWork
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
09a3b223
authored
Oct 24, 2020
by
李楚霏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
work08
parent
8f69997b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
72 additions
and
0 deletions
+72
-0
work08/8_8_2.cpp
+34
-0
work08/8_8_4.cpp
+38
-0
No files found.
work08/8_8_2.cpp
0 → 100644
View file @
09a3b223
#include<iostream>
#include<cstring>
using
namespace
std
;
struct
candyBar
{
/* data */
char
name
[
30
];
double
weight
;
int
colorie
;
};
void
setCandyBar
(
candyBar
&
,
const
char
*
n
=
"aabb"
,
double
w
=
2.10
,
int
c
=
19
);
void
printBar
(
candyBar
&
);
int
main
()
{
candyBar
CB
;
setCandyBar
(
CB
);
char
name
[]
=
"munch"
;
double
weight
=
12.11
;
int
colorie
=
10
;
setCandyBar
(
CB
,
name
,
weight
,
colorie
);
printBar
(
CB
);
return
0
;
}
void
setCandyBar
(
candyBar
&
cb
,
const
char
*
n
,
double
w
,
int
c
)
{
strcpy
(
cb
.
name
,
n
);
cb
.
weight
=
w
;
cb
.
colorie
=
c
;
}
void
printBar
(
candyBar
&
cb
)
{
cout
<<
cb
.
name
;
cout
<<
cb
.
weight
;
cout
<<
cb
.
colorie
<<
endl
;
}
\ No newline at end of file
work08/8_8_4.cpp
0 → 100644
View file @
09a3b223
#include<iostream>
using
namespace
std
;
#include<cstring>
struct
stringy
{
/* data */
char
*
str
;
int
ct
;
};
void
set
(
stringy
&
,
const
char
*
test
);
void
show
(
stringy
&
,
int
num
=
2
);
void
show
(
const
char
*
test
=
"aabb"
,
int
num
=
3
);
int
main
()
{
stringy
beany
;
char
testing
[]
=
"Reality isn't what it used to be"
;
set
(
beany
,
testing
);
show
(
beany
);
show
(
beany
,
2
);
testing
[
0
]
=
'D'
;
testing
[
1
]
=
'u'
;
show
(
testing
);
show
(
testing
,
3
);
show
(
"Done!"
);
return
0
;
}
void
set
(
stringy
&
s
,
const
char
*
test
)
{
strcpy
(
s
.
str
,
test
);
}
void
show
(
stringy
&
s
,
int
num
)
{
s
.
ct
=
num
;
}
void
show
(
const
char
*
test
,
int
num
)
{
cout
<<
"test:"
<<
test
;
cout
<<
num
<<
endl
;
}
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