עבור לתוכן
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, את התרגיל הבא:

פתח ויישם אלגוריתם המקבל כקלט עשר אותיות ומציג את מספר האותיות הזהות לאות הראשונה שנקלטה.

עכשיו הנה הקוד שלי רק שפה זה עם מספרים ואני רוצה עם אותיות אני פשוט לא יודע איך ואני לא מוצא בספר שום הסבר.

#include <stdio.h>

#include <conio.h>

void main()

{

clrscr();

int ot1,ot2;

int mone,i;

mone = 0;

scanf("%d",&ot1);

for(i = 2; i <= 10; i++)

{

scanf("%d",&ot2);

if(ot2 == ot1)

mone++;

}

printf("\n %d",mone);

}

תודה מראש לכל העוזרים.

פורסם

זה פשוט את כל מה שמתיחס למספרים(INT) אתה משנה לתוים (CHAR)

ואת הבדיקה עושים כך

if('char1'=='char2')

פורסם

int ot1,ot2;

תשנה לCHAR.

ותעשה %c בSCANF

דרך אגב, תמחק תMONE ותרשום counter או משהו באנגלית עם משמעות ולא את התעתיק.

פורסם

שלום נתנו לי תרגיל בספר שאני לומד בו C את התרגיל הבא:

פתח ויישם אלגוריתם המקבל כקלט עשר אותיות, ומציג את מספר האותיות הזהות לאות הראשונה שנקלטה.

עכשיו הנה הקוד שלי, רק שפה זה עם מספרים ואני רוצה עם אותיות. אני פשוט לא יודע איך, ואני לא מוצא בספר שום הסבר.

#include <stdio.h>
#include <conio.h>

void main()
{
int i;
int counter = 0;
char ch1, ch2;

clrscr();

scanf( "%c", &ch1 );

for( i = 0; i < 9; i++ )
{
scanf( "%c", &ch2 );
if( ch1 == ch2 )
{
counter++;
}
}

printf( "%d\n", counter );
}

אתה בטוח שזה C, ולא ++C? ב-C אסור להגדיר משתנים באמצע פקודות.

פורסם
  • מחבר

ניסיתי זה לא עובד זה נותן לי 0 אחרי שאני מכניס את הקלט.

פורסם

אתה מכניס את הקלט עם 'Enter' אחרי כל אות (אני חושב שאפשר גם רווחים)?

ארכיון

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

דיונים חדשים

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.