5782SemBMoedA

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

‫בס"ד‬

‫סמסטר א' תשפ"ד‬ ‫מבוא למדעי המחשב‬

‫בוחן אמצע – חלק ב'‬

‫‪English instructions follow the Hebrew Instructions‬‬


‫בחלק זה שאלה אחת‪ .‬עליך להתחיל חלק זה רק אחרי שסיימת את החלק הראשון של הבוחן האמצע‪ .‬מומלץ‪,‬‬
‫אך לא חובה‪ ,‬לעבוד בויזואל סטודיו‪.‬‬
‫עליך להגיש חלק זה עד השעה ‪ .11:50‬מומלץ להקדיש ‪ 30‬דקות לחלק זה‪ ,‬ולהגיש כבר אחרי ‪ 30‬דקות (בשעה‬
‫‪ )11:40‬כך שיישארו לך עוד ‪ 10‬דקות להגשת השאלה במודל‪ ,‬למקרה של בעיות בהגשה‪.‬‬
‫צורת ההגשה של פתרון שאלה זו דומה לצורת ההגשה של תרגילי הבית‪ ,‬מלבד זה שלא תקבל משוב מהבודק‬
‫האוטומטי‪.‬‬
‫עליך לכתוב תכנית אשר תקלוט מהמשתמש מספר שלם אשר מספר הספרות בו לא ידוע‪.‬‬
‫על התכנית לחשב את המספר הבנוי מהספרות אשר במקומות האי זוגיים בלבד (אחדות‪ ,‬מאות‪ ,‬וכו') ולהדפיס‬
‫את המספר החדש שבנית‪.‬‬
‫לדוגמא –‬
‫אם הקלט יהיה ‪ 182‬על התכנית לחשב את המספר ‪.12‬‬ ‫‪-‬‬
‫אם הקלט יהיה ‪ 1239656‬הפלט יהיה ‪.1366‬‬ ‫‪-‬‬
‫אם הקלט יהיה ‪ 1234567‬הפלט יהיה ‪.1357‬‬ ‫‪-‬‬

‫יש להכניס את הקוד במקום המיועד לכך בתוך התכנית הבאה‪ ,‬כך שבמשתנה ‪ oddDigNum‬יהיה המספר החדש‬
‫שיצרת‪ .‬אין למחוק או לשנות דבר מהקוד הרשום פה‪ .‬יש להוסיף קוד רק במקום המיועד לכך‪.‬‬
‫>‪#include <iostream‬‬
‫;‪using namespace std‬‬

‫*‪/‬‬
‫‪Fill here your details:‬‬
‫‪Name:‬‬
‫‪Id:‬‬
‫‪*/‬‬

‫{ )(‪int main‬‬

‫;‪int num‬‬

‫;‪cin >> num‬‬


‫;‪int oddDigNum‬‬

‫*‪/‬‬

‫‪Here you have to insert your code‬‬

‫‪*/‬‬
‫;‪cout <<"The new number is: " << oddDigNum‬‬

‫;‪return 0‬‬
‫}‬
‫בס"ד‬

‫סמסטר א' תשפ"ד‬ ‫מבוא למדעי המחשב‬

‫בוחן אמצע – חלק ב'‬

‫יש להגיש את הקוד כולו‪ ,‬בתיבת ההגשה הנקראת בוחן אמצע חלק ב' עד השעה ‪ 11:50‬ולכן מאוד מומלץ לנסות‬
‫להגיש את בוחן האמצע לפני שעה זו‪ ,‬מי שלא מצליח להגיש את הבוחן בזמן (עד השעה ‪ )11:50‬עליו לפעול כך‪:‬‬

‫לדווח בטופס שנמצא בתוך נושא הבוחן במודל על הבעיה‪,‬‬ ‫‪‬‬


‫ואחר כך להגיש שוב (הפעם תהיה תיבה נפרדת עבור מי שלא מצליח להגיש בתיבה הרגילה) שם‬ ‫‪‬‬
‫התיבה הוא "תיבת הגשה ‪ -‬להגשה באיחור"‪.‬‬

‫כל הגשה באיחור תישקל לגופה על פי הטופס שמילאתם‪ .‬תזכורת‪ :‬מטרת התיבה של הגשה באיחור היא‬
‫לטפל בבעיות של המודל‪ .‬כל סיבה אחרת לא תתקבל‪.‬‬

‫התיבה תיסגר סופית בשעה ‪ 12:05‬בלי הזדמנות להגיש אחר כך‪.‬‬


‫בס"ד‬

‫סמסטר א' תשפ"ד‬ ‫מבוא למדעי המחשב‬

'‫בוחן אמצע – חלק ב‬

This part has one question. You can begin this part only after completing Part A. It is advisable for you
to use Visual Studio but not necessary.
You need to hand in this part no later than 11:50 a.m. It is advisable for you to submit it after 30
minutes (aka 11:40) so that you will have 10 minutes spare to deal with problems in submitting the file
should such a problem occur.
The submission box is similar to the one that you are already familiar with for submitting your
homeworks. (The only difference is that now you will not receive a grade from the automatic grader.)

You are to write a program that will receive a number as input. It is not known how many digits
are in the number. The program is to build a new number that it made up of all of the digits from
the original number that appear in an “odd” place (aka the digit in the ones place and then the
digit in the 100s place etc) and output that number.
For example,

 if the input is 182 then the output should be 12


 If the output is 1239656 then the output should be 1366

You are to only add code to the place that is specified in the program below in such a way that
the variable oddDigNum will contains the value of the number that you built.
You may not erase nor change any of the code that are already written. You are only to add
code to the designated area.

#include <iostream>
using namespace std;

/*
Fill here your details:
Name:
Id:
*/

int main() {

int num;

cin >> num;


int oddDigNum;

/*

Here you have to insert your code

*/
cout <<"The new number is: " << oddDigNum;

return 0;
}
‫בס"ד‬

‫סמסטר א' תשפ"ד‬ ‫מבוא למדעי המחשב‬

'‫בוחן אמצע – חלק ב‬

You are to submit Part B by 11:50 a.m. (the entire program) in the submission box titled Midterm – Part
B
It is highly recommended that you try and submit before. If you encounter problems uploading your file
at 11:50 you must:
 Immediately let us know of the problem. A link to the form for reporting problems will be available
in Moodle.
 Afterwards, upload your file again. (This time there will be a separate box for anyone who could not
hand in their program on time. The title of the submission box is “Submission Box – for late
submissions”)
We will take into consideration what you filled out in the form when deciding upon whether or not
to accept your excuse. The purpose of the late submission box is to take care of problems that were
cause by Moodle. Any other reason for submitting late will not be accepted.
 The submission box will automatically close at 12:05 and afterwards, you will not have the
opportunity to submit your file.

You might also like