-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into my-new-branch
- Loading branch information
Showing
6 changed files
with
61 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
Program's_Contributed_By_Contributors/C++_Programs/addZeroToFirstIndex.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#include <iostream> | ||
#include <vector> | ||
using namespace std; | ||
|
||
void shift(vector<int>& array); | ||
|
||
int main() { | ||
vector<int> arr = {1,0,4,3}; | ||
shift(arr); | ||
for (int j = 0; j < arr.size(); j++) { | ||
cout << arr[j] << " "; | ||
} | ||
cout << endl; | ||
} | ||
void shift(vector<int>& array) { | ||
for (int i = array.size() - 2; i >= 1; i--) { | ||
array[i+1] = array[i]; | ||
} | ||
array[1] = 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
Program's_Contributed_By_Contributors/Rust_Programs/default-args.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Source: https://www.sudipg.com.np/posts/default-argument-rust-using-macro/#-solution | ||
|
||
macro_rules! print_this { | ||
($a: expr) => { | ||
print_this_raw($a, 0, 0); | ||
}; | ||
($a: expr, $b: expr) => { | ||
print_this_raw($a, $b, 0); | ||
}; | ||
($a: expr, $b: expr, $c: expr) => { | ||
print_this_raw($a, $b, $c); | ||
}; | ||
} | ||
|
||
fn print_this_raw(a: i32, b: i32, c: i32) { | ||
println!("a = {} >> b = {} >> c = {}", a, b, c); | ||
} | ||
|
||
fn main() { | ||
// a = 10, b = 0, c = 0 | ||
print_this!(10); | ||
|
||
// a = 10, b = 20, c = 0 | ||
print_this!(10, 20); | ||
|
||
// a = 10, b = 20, c = 30 | ||
print_this!(10, 20, 30); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters