-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Write JS Code for getting weather condition #180
- Loading branch information
1 parent
0d47af5
commit eb78f15
Showing
4 changed files
with
91 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#include <iostream> | ||
using namespace std; | ||
|
||
struct TreeNode { | ||
|
||
int data; | ||
TreeNode *left, *right; | ||
|
||
TreeNode(int val) { | ||
|
||
data = val; | ||
left = nullptr; | ||
right = nullptr; | ||
} | ||
}; | ||
|
||
TreeNode* constructTreeFromArray(int nums[], int start, int end) { | ||
|
||
if (start > end) { | ||
|
||
return nullptr; | ||
} | ||
|
||
int mid = start + (end - start) / 2; | ||
TreeNode* node = new TreeNode(nums[mid]); | ||
|
||
node->left = constructTreeFromArray(nums, start, mid - 1); | ||
node->right = constructTreeFromArray(nums, mid + 1, end); | ||
|
||
return node; | ||
} | ||
|
||
TreeNode* sortedArrayToBST(int nums[], int size) { | ||
|
||
if (size == 0) { | ||
|
||
return nullptr; | ||
} | ||
|
||
return constructTreeFromArray(nums, 0, size - 1); | ||
} |
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,29 @@ | ||
#include <iostream> | ||
#include <cmath> | ||
using namespace std; | ||
|
||
int main(){ | ||
int n; | ||
cin >> n; | ||
|
||
int x; | ||
x = floor(n/2); | ||
if(n%2 == 1){ | ||
if(x%2==1){ | ||
cout << '0' << endl; | ||
} | ||
else{ | ||
cout<<'1'<<endl; | ||
} | ||
|
||
} | ||
else{ | ||
if(x%2==0){ | ||
cout << '0' << endl; | ||
} | ||
else{ | ||
cout<<'1'<<endl; | ||
} | ||
} | ||
|
||
} |
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,7 @@ | ||
fetch('https://pokeapi.co/api/v2/pokemon/pikachu') | ||
.then(res => res.json()) | ||
.then(data => { | ||
console.log('name: ' + data.name); | ||
console.log('pokemon type: ' + data.types.map(type => type.type.name)); | ||
console.log('abilities: ' + data.abilities.map(ability => ability.ability.name).join(', ')); | ||
}); |
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,14 @@ | ||
<html> | ||
<head> | ||
<script> | ||
function rollDice() { | ||
var dice1 = Math.floor(Math.random() * 6) + 1; | ||
alert("You rolled : " + dice1); | ||
} | ||
</script> | ||
</head> | ||
<body> | ||
<h1>Dice Roll</h1> | ||
<button onclick="rollDice()">Roll Dice</button> | ||
</body> | ||
</html> |