سلام عليكم ورحمة الله وبركاته
البرنامج الهدف منه تجميع بيانات لشخص واحد من كل فئه عمريه بحيث لايوجد شخصين لهم نفس العمر (هذا البرنامج للتعليم فقط وليس برنامج حقيقى)
المشكله التى تواجهنا ان المستخدم يستطيع ادخال نفس قيمه الاعمار (الاعمار تتكرر) اريد ان يبقى العمر unique اى لا يتكرر هذه محاولاتى
رابط الكود بشكل منسق أكثر
http://pastebin.com/zLPAQJ7m
#include<conio.h>#include<stdio.h>#define size 3 struct emp { int age,overtime,dedcution,netsal; float salary; char firstname[15]; char lastname[15]; }; int main() { int i,j,unq=1,arr[3]={0}; float temp=0.0; struct emp employes[3]; clrscr(); printf("please insert data of employee\n"); for(i=0;i<size;i++) { clrscr(); gotoxy(5,2); printf("firstname"); gotoxy(40,2); printf("lastname"); gotoxy(5,4); printf("age"); gotoxy(40,4); printf("salary"); gotoxy(5,6); printf("overtime"); gotoxy(40,6); printf("nset salary"); gotoxy(16,2); scanf("%s", employes.firstname); gotoxy(50,2); scanf("%s",employes.lastname); gotoxy(10,4); scanf("%d",&employes.age); arr[0]=employes[0].age; for(j=i+1;j<size;j++) { if(arr == employes[j].age ) { unq=0; break; } } if(unq==0) { gotoxy(10,4); scanf("%d",&employes.age); }else{ arr=employes[i+1].age; } /* for(j=i+1;j<size;j++) { if(arr == employes[j].age) { unq=0; break; } } if(!unq) unq=1; goto Ask; */ gotoxy(50,4); scanf("%f",&temp); // employes.salary=0; employes.salary =temp; gotoxy(20,6); scanf("%d",&employes.overtime); gotoxy(55,6); scanf("%d",&employes.netsal); } clrscr(); for(i=0;i<size;i++) { printf("first name :\t %s \n",employes.firstname); printf("last name :\t %s \n ",employes.lastname); printf("age:\t %d \n",employes.age); printf("salary:\t %f \n",employes.salary); printf("overtime:\t %d \n",employes.overtime); printf("netsal :\t %d \n",employes.netsal); printf("\n _______________________ \n"); } getch(); return 0; }