السلام عليكم و رحمة الله و بركاته
عندي واجب مطلوب مني أحله و حتى اﻵن محاولاتي باءت بالفشل .... راح اضع السؤال باللغة اﻹنجليزية مع محاولتي ....
شرح بسيط للسؤال: الجهاز يولد أرقام من 1 ألى 15 بحيث أن A=b-c و b=d-e و هكذا علما بأنه ممنوع تكرار اي رقم و استخدام abs مع عملية الطرح..
تكفووون سااااعدوني علما بأنني استخدم اللينكس و كومبايلر emacs
اقتباسExercise 4: triangle.c (2.5 marks).Finds all possible ways of assigning the numbers 1 to 15 to the letters A to O such that in the
triangle below, any number not on the last row is the absolute value of the difference between the
two neighbours on the row below.
A
B C
D E F
G H I J
K L M N O
The output of your program, saved as triangle.c, should be a vertical sequence of triangles (one
triangle for each found solution) of the form above, with of course the letters being replaced by
appropriate numbers. There is no constraint on the occurrences of spaces—just make sure your
triangles look like triangles. . .
Your program should not make any assumption on the actual solution.
و هذه محاولتي المتواضعة بعمل برنامج مصغر للسؤال و يولد من 1- 10 لم يتم اضافة حروف k, l, m, n, o
#include <stdlib.h>
#include <math.h>
int main(void) {
for( int g=1; g<=10;g++){
for(int h=1; h<=10 ; h++){
for(int i=1;i<=10;i++){
for(int j=1; j<=10 ;j++){
int d=abs(g-h);
int e=abs(h-i);
int f=abs(i-j);
int b=abs(d-e);
int c=abs(e-f);
int a=abs(b-c);
if(a=!b && a!=c && a!=d && a!=e && a!=f && a!=g && a!=h && a!=i && a!=j && b!=c && b!=d && b!=e && b!=f && b!=g && b!=h && b!=i && b!=j && c!=d && c!=e && c!=f && c!=g && c!=h && c!=i && c!=j && d!=e && d!=f && d!=g && d!=h && d!=i && d!=j && e!=f && e!=g && e!=h && e!=i && e!=j && f!=g && f!=h && f!=i && f!=j && g!=h && g!=i && g!=j && h!=i && h!=j){
printf(" %d \n",a);
printf(" %d %d \n",b,c);
printf(" %d %d %d \n",d,e,f);
printf("%d %d %d %d\n",g,h,i,j);
}
}
}
}
}
return EXIT_SUCCESS;
}
#include <stdio.h>
مع العلم بأن
the maximum number of indentations is set to 7