Skip to content

Commit

Permalink
Implement 16.
Browse files Browse the repository at this point in the history
  • Loading branch information
alxest committed Aug 9, 2015
1 parent 3021fe1 commit 38c3140
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
11 changes: 11 additions & 0 deletions 16.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,19 @@ void Divide(int x, int y, int *result, int *remainder) {
*remainder = x % y;
}

void ParamArray(int length, ...) {
va_list args;
va_start(args, length);
cout << length << endl;
for(int i=0; i<length; i++) {
cout << va_arg(args, int) << " ";
}
cout << endl;
}

int main() {
int res, rem;
Divide(10, 3, &res, &rem);
cout << res << " " << rem << endl;
ParamArray(4,5,2,6,8);
}
7 changes: 7 additions & 0 deletions 16.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,15 @@ static void Divide(int x, int y, out int result, out int remainder) {
result = x / y;
remainder = x % y;
}
static void ParamArray(params int[] args) {
Console.WriteLine(args.Length);
for(int i=0; i<args.Length; i++)
Console.Write(args[i] + " ");
Console.WriteLine();
}
static void Main() {
int res, rem;
Divide(10, 3, out res, out rem); Console.WriteLine("{0} {1}", res, rem);
ParamArray(5,2,6,8);
}
}

0 comments on commit 38c3140

Please sign in to comment.