עבור לתוכן
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

פורסם

הבעיה שאתה מנסה להדפיס מערך דו מימדי כאשתה רושם line .

בעוד שלמשל אם נסתכל על "was"

ב-line אין את המחרוזת הזאת אלא יש 3 מחרוזות("w","a","s")

לכן עדיף להשתמש במערך דו ולא תלת מימדי.

בכל מקרה אפשר לפתור את הבעיה ע"י הדפסת המחרוזות ב-line עד שנקבל מחרוזת רחקה

שמסמלת סוף מילה כמו שעשיתי כאן:

http://tennis.bravehost.com/filpWords.txt

כמו-כן שים לב שלא חייבים להשתמש ב-flag אלא פשוט לבודד את המקרים

עם else if מאחר וידוע שרק מבצ אחד אפשרי כל פעם כולל טעות.

פורסם
  • מחבר

תודה רבה לך עמית.

בתוכנית שלך ישנה בעייה קטנה. לדוגמא, עבור הקלט:

I love America. I love USA.

הפלט הוא:

America Love I..

בתוכנית שלך נעשו שני שינויים בלבד:

שורת הקוד:

else if (char_A <= toupper(letter) && toupper(letter) <= char_Z)

הוחלפה בושרת הקוד:

else if ((char_A<=letter && letter<=char_Z) || (char_a<=letter && letter<=char_z))

ונמחקו שלושת השורות הראשונות של הקוד, הקוראות לתקיות conio, schar ו stdlib.

תודה מראש.

פורסם

הוספתי אותם כי רציתי לעשות משהו שבסוף לא עשיתי.

התוכנית רצה גם בלעדיהם.

פורסם
  • מחבר

נכון, הרצתי אותה.

אך, יש לך מושג לגבי הבעייה?

עריכה:

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

#include <stdio.h>
#include <string.h>
#define max_letters 32
#define char_A 'A'
#define char_Z 'Z'
#define char_a 'a'
#define char_z 'z'
#define enter 10
#define space 32
#define dot '.'
#define null '\0'

int main()
{
int i=0, j=0, k=0, temp_k, length_sentence, length_line, flag_error=0;
char letter, sentence[max_letters]="", temp_line[max_letters]="", temp_reverse[max_letters]="", final_sentence[max_letters]="";
do
{
scanf("%c", &letter);
if (letter==enter)
continue;
sentence[i]=letter;
i++;
printf("%s", sentence);
}
while(letter!=enter);
length_sentence=i-1;
/*for (i=0; i<=length_sentence; i++)
if ((char_A<=sentence[i] && sentence[i]<=char_Z) || (char_a<=sentence[i] && sentence[i]<=char_z) || sentence[i]==space || sentence[i]==dot || letter==enter)
flag_error++;
if (flag_error==length_sentence-1)
{*/
sentence[31]=null;
i=0;
for (i=0; i<=length_sentence; i++)
if (sentence[i]=dot)
final_sentence[i]=dot;
strcat(temp_line, sentence);
temp_line[i]=null;
printf("tp:%s", temp_line);
do
{
length_line=i-1;
k=0;
while(temp_line[length_line-k]!=space)
k++;
temp_k=k;
for (k=length_line-temp_k; k<=length_line; k++)
{
temp_reverse[j]=temp_line[k];
j++;
}
temp_line[length_line-temp_k-1]=null;
temp_reverse[j]=space;
j++;
}
while(k>=0);
strcat(final_sentence, temp_reverse);
printf("%s", final_sentence);
printf("fs: %s\n", final_sentence);
/*}
else
printf("error\n"); */
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.