*4. Phone: Arrays - More Exercises
Днес, докато търсех допълнителните упражнения за масиви попаднах на една задача от 2017г , която е отпаднала в сегашните курсове на C# Fundamentals: https://judge.softuni.bg/Contests/Practice/Index/422#3 Стори ми се доста интересна и реших да я направя, но получих 0/100 за жалост. Мисля, че проблема ми е отново при принтирането на минутите и секундите след изчисляването на сумата от числата на получения телефонен номер, тоест от получената сума на числата трябва да получим минути и секунди. Мисля, че този път не е проблема в MonoDevelop. Моля, ако някой може да погледне последните три реда от кода ми, защото само те не излизат правилно в аутпута и като цяло метода sum(). https://pastebin.com/ynfGYjzD
While I was searching today for additional exercises about arrays I stumble upon one exercise from 2017, which is not included today in C# Fundamental module: https://judge.softuni.bg/Contests/Practice/Index/422#3 I have decided to give it a try, but unfortunately I scored 0/100. I think the problem is in my print method for minutes and seconds after calculate the sum of digits in given phone number. Exactly from current sum of digits we have to print minutes and second for call duration. I think this time the root of problem is not a MonoDevelop. Can somebody please help me out and give me feedback why my code is not working, I will be very grateful. I think the problem is in the last three lines in my code and in sum().
https://pastebin.com/ynfGYjzD
3. Phonebook-previous problem
You will be given an array of phone numbers (strings) and an array of names (strings). After which, you will be given strings on new lines, until you receive the command “done”. Find the numbers, which correspond to the names and print them on the console in the following format:
-
{name} -> {number} // (this line is not included in my task)
A number corresponds to a name when it’s located on the same position as its corresponding name in both arrays.
4.* Phone- my problem
This is an upgrade of the previous problem. Implement the phonebook functionality from the previous problem with this additional functionality:
-
call {number/name} -> print “calling {name/number}…”
-
If the sum of the digits (ignore other characters) of the number is odd, print “no answer”.
-
If the sum of the digits (ignore other characters) of the number is even, print “call ended. duration: {duration}”. The duration is calculated from the sum of the digits in the format “mm:ss”
-
-
message {number/name} -> print “sending sms to {name/number}...”
-
if the difference of the digits (ignore other characters) of the number is odd, print “busy”
-
if the difference of the digits (ignore other characters) of the number is even, print “meet me there”
-
Input |
0888888888 0888123456 +359886001122 Nakov Ivan Maria call 0888888888 call Ivan message Maria done |
Output:
calling Nakov... call ended. duration: 01:12 calling 0888123456... no answer sending sms to +359886001122... busy |
Output in Judge: 0/100
calling Nakov...
call ended. duration: 09:12
calling 0888123456...
no answer
sending sms to +359886001122...
busy
Thanks again!
I was adding also ASCII value and for differences, but I corrected it. I chose the first way, because directly taken int result.
for (int i = 0; i < phoneNumber.Length; i++)
{
if (int.TryParse(phoneNumber[i].ToString(), out int result))
{
difference = difference - result;
}
}
I have already working code thanks to you: https://pastebin.com/NBLpAY9T And this was my last exercise before exam preparation. I have solved twice all exercises in Fundamental module without one about Longest Increasing Subsequence with Dinamic programming. I don't worry about that, because I will take algorithm course with Dinamic programing after my C# OOP. And really I think to programming with MonoDevelop is potential risk for C#Advanced and OOP.
Best regards!
Eli