-
Notifications
You must be signed in to change notification settings - Fork 164
feat: git commit -m feat: I use maps to simplify use #463
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
LeottaAlberto
wants to merge
6
commits into
UNICT-Quality-Development:main
Choose a base branch
from
LeottaAlberto:ex4_LA
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
13be537
feat: git commit -m feat: I use maps to simplify use
LeottaAlberto 04e4e68
refactor: load old code
LeottaAlberto 1b7abbb
feat: git commit -m feat: I use maps to simplify use
LeottaAlberto 9c2791f
refactor(ex4.cpp): add namespace, remove std:: and add more spaces
LeottaAlberto 6e8a4da
style(ex4.cpp): remove whitespaces
LeottaAlberto 26ab2f8
style(ex4.cpp): remove whitespace
LeottaAlberto File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
| @@ -1,56 +1,67 @@ | ||
| /* Surprise me. */ | ||
|
|
||
| #include <stdio.h> | ||
|
|
||
| int main() | ||
| { | ||
| int month; | ||
|
|
||
| /* Input month number from user */ | ||
| printf("Enter month number(1-12): "); | ||
| scanf("%d", &month); | ||
|
|
||
| switch (month) | ||
| { | ||
| case 1: | ||
| printf("31 days"); | ||
| break; | ||
| case 2: | ||
| printf("28/29 days"); | ||
| break; | ||
| case 3: | ||
| printf("31 days"); | ||
| break; | ||
| case 4: | ||
| printf("30 days"); | ||
| break; | ||
| case 5: | ||
| printf("31 days"); | ||
| break; | ||
| case 6: | ||
| printf("30 days"); | ||
| break; | ||
| case 7: | ||
| printf("31 days"); | ||
| break; | ||
| case 8: | ||
| printf("31 days"); | ||
| break; | ||
| case 9: | ||
| printf("30 days"); | ||
| break; | ||
| case 10: | ||
| printf("31 days"); | ||
| break; | ||
| case 11: | ||
| printf("30 days"); | ||
| break; | ||
| case 12: | ||
| printf("31 days"); | ||
| break; | ||
| default: | ||
| printf("Invalid input! Please enter month number between 1-12"); | ||
| } | ||
| #include <iostream> | ||
| #include <string> | ||
| #include <map> | ||
|
|
||
| using namespace std; | ||
|
|
||
| const int ZERO = 48; | ||
| const int NINE = 57; | ||
| const int MAX_NUMBER = 10; | ||
| const int MINUS = 45; | ||
|
|
||
| const string ERROR_COLOR = "\033[31m"; | ||
| const string NORMAL_COLOR = "\033[0m"; | ||
|
|
||
| int insertNumber(); | ||
| bool checkStringIsNumber(string in); | ||
|
|
||
| int main(){ | ||
| int month = insertNumber(); | ||
| map<int, string> calendary = { | ||
| {1, "31"}, | ||
| {2, "28/29"}, | ||
| {3, "31"}, | ||
| {4, "30"}, | ||
| {5, "31"}, | ||
| {6, "30"}, | ||
| {7, "31"}, | ||
| {8, "31"}, | ||
| {9, "30"}, | ||
| {10, "31"}, | ||
| {11, "30"}, | ||
| {12, "31"}, | ||
| }; | ||
| cout << calendary[month] << " days"; | ||
| return 0; | ||
| } | ||
|
|
||
| int insertNumber(){ | ||
| string insert; | ||
| bool isCorrect = true; | ||
|
|
||
| do { | ||
| if(!isCorrect) cout << ERROR_COLOR+("[Insert a valid input] ")+NORMAL_COLOR; | ||
|
|
||
| cout << "Insert Mounth: "; | ||
| getline(cin, insert); | ||
|
|
||
| isCorrect = checkStringIsNumber(insert); | ||
| } while(!isCorrect); | ||
|
|
||
| return stoi(insert); | ||
| } | ||
|
|
||
| bool checkStringIsNumber(string in){ | ||
| if(in.empty()) | ||
| return false; | ||
|
|
||
| for(int i = 0; i < in.size(); i++) | ||
| if((in.at(i) < ZERO || in.at(i) > NINE) && in.at(i) != MINUS) | ||
| return false; | ||
|
|
||
| if(stoi(in) > MAX_NUMBER) return false; | ||
|
|
||
| return true; | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
idem