13-01-2009, 18:38
|
מנהל
|
|
חבר מתאריך: 26.07.08
הודעות: 6,473
|
|
לפי מה את יודעת מה הטווח?
קלטת רק integer אחד מהמשתמש... את חייבת לקלוט 2 מספרים שלמים כדי שיהיה טווח מסויים, שתוכלי להדפיס את המספרים האי-זוגיים שבתוכו.
אכתוב לך קוד המתבסס על הקוד שלך:
קוד:
int main()
{
unsigned int min=0, max=0; /* We're not using the `j` variable to make your program a bit more efficient */
// Welcome text
printf("\n\t\t***ezoogie***\n\n");
while(max<=min) // As long as max is smaller than (or equal to) min
{
// Instructions
printf ("\tPleae enter 2 numbers between 1-1000, seperated by space. \n
The first number should be smaller than the last.\n\n");
// Receive input from the user
scanf ("%d %d", &min, &max);
}
if (!(min & 1)) // Is it zoogi?
++min; // Make it e-Zoogi
for (; min<=max; min += 2 /* Now we just have to add 2 to the `min` variable */ )
{ printf("%d\n", min); }
puts("All the e-Zoogie numbers have been printed. Program finished. bye...\n (Press a key to exit)");
getch();
return 0;
}
|