18-01-2009, 16:27
|
|
|
|
חבר מתאריך: 10.10.06
הודעות: 64
|
|
ציטוט:
במקור נכתב על ידי rlsf
איזה שילוב של מספרים נחשב "חוקי"? רק הסדרה 2,5,7 או שכל שלוש מספרים בודדים?
|
כל שלושה מספרים בין 1 ל 10 שיראו כך למשל:
1 5 7 (רווח אחד ביניהם)
מה שכתבתי עד כה:
קוד PHP:
#include <stdio.h> int main (void) { char Q1c=0; char Q2c=0; char Q3c=0; char Q11c=0; char Q22c=0; char Q33c=0; printf ("Begin a new set of questions. Please enter the numbers of the test questions:\n"); scanf("%c %c %c", &Q1c, &Q2c, &Q3c); /* convert the input into ASCII values?*/ Q11c=Q1c + Q22c=Q2c + Q33c=Q3c + while ( (Q11c < 49) || (Q11c > 57) || (Q22c < 49) || (Q22c > 57) || (Q33c < 49) || (Q33c > 57) ){ printf("Illegal numbers. Please enter the numbers of the test questions:\n\n"); scanf("%c %c %c", &Q1c, &Q2c, &Q3c); } אני רק צריכה את הנוסחא להמיר 3 משתנים Q1c Q2c Q3c למספר ה ASCII שלהם ככה שאם אני מכניסה את Q1c להיות a אז Q11c יהיה 97..
|