עבור לתוכן
View in the app

A better way to browse. Learn more.

HWzone

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

כתיבת תוכנה, המרת ספרות שפת C

Featured Replies

פורסם

שלום לכולם

יש לי תרגיל בשפת C. אני צריך לכתוב תוכנה שהמשתמש מכניס מספר והתוכנה הופכת את זה לספרות רומיות.

אני לא ממש מוצא דרך שהתוכנה תקבל מספר ותמיר את זה לאותיות נגיד שיכניסו 3 ויתקבל III. מישהו יכול לעזור לי?

תודה

:yelclap:

פורסם

הרעיון הכללי הוא לבצע חלוקה של המספר העשרוני לספרות הרומיות מהגדולה ביותר לקטנה ביותר בשילוב עם % (Mod)

מקווה והרמז עזר.

פורסם
  • מחבר

וואי אני הכי גרוע שאפשר עם חלוקה כזאת. תוכל לתת לי דוגמה קטנה למה אתה מתכוון?

פורסם

int number - הוא הקלט

תחילה נבצע

number \ 1000 = מספר הM-ים

number % 1000 = reminder

reminder \ 500 = מספר הD-ים (תמיד או אחד או 0)

reminder % 500 = newReminder

וכך הלאה

למעשה קיבלת פה 90% מהתשובה.

אני מאמין שמפה תסתדר לבד.

פורסם

הנה הצעה שלי:


#include <stdio.h>

typedef char * String;
int main()
{
String units[] = { "I" , "II", "III", "IV", "V", "VI", "VII", "VIII", "IX" };
String dozens[] = { "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC" };
String hundreds[] = { "C", "CC" , "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM" };
int i, unit_dig, dozen_dig, hundred_dig, thousand_dig, num;

printf("Write a decimal number \n");
scanf("%d", &num);

unit_dig = num % 10;
dozen_dig = num / 10 % 10;
hundred_dig = num / 100 % 10;
thousand_dig = num / 1000;

for( i=0; i < thousand_dig; i++) printf("M");

if(hundred_dig != 0)
printf("%s", hundreds[hundred_dig-1]);

if(dozen_dig != 0)
printf("%s", dozens[dozen_dig-1]);

if(unit_dig != 0)
printf("%s", units[unit_dig-1]);

return 0;
}

ארכיון

דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.

דיונים חדשים

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.