Click here to Skip to main content
16,022,669 members

Comments by zahraZa (Top 5 by date)

zahraZa 29-Jan-12 3:38am View    
i want to write 8-puzzle code in prolog. for storing number from 1 to 8 i need an array. I think i should use array, is it true?
zahraZa 29-Jan-12 3:29am View    
i have read all of them , but i want to access easy to array elements ( but in List this is difficult).
zahraZa 23-Jun-11 13:41pm View    
thanks a lot,
but i don't want to use .read because user must can read records that saved in file(address of records in the file are random).File saveF must be readable.if i use txt file i should write field by field of my class(true?)if this is true can i access to record by random address ?
i don't know what should to do!!!!! :(
thanks for your help
zahraZa 23-Jun-11 6:58am View    
this is my code:
<prev>
void myclass::Get(){
ofstream saveF("c:/ms/SAVE.txt",ios::binary);
if(!saveF){
cout&lt;&lt;"\n\t\t\t ! Sorry can't open !\n";
exit(1);
}
else{
static string charset = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
myclass myRecord;
string result;
myclass *tmyclass=new myclass();
int myArray[10]={0};
srand(time(NULL));
node=new myclass();
for(int i=0;i&lt;10000;i++){
myRecord.code=rand()%999+10000;
myRecord.Dgenerate = rand()%(21)+1350;
myRecord.Dexpire= = rand()%(21)+1370;
for(int m=0;m&lt;9;m++){
myRecord.name[m]=charset[rand()%charset.length()];
}
myRecord.purity==rand()%(98)+1;
long int sCode=(myRecord.code)*(myRecord.code);int address=0,F=1;
for(int j=9;j&gt;-1;j--){
myArray[j]=sCode%10;
sCode=sCode/10;
if((j>3) &&(j<7)){
address+=F*myArray[j];
F*=10;
}
}
address*=0.7;
saveF.write((char *)&myRecord,address *( sizeof(myRecord)));
if(i==0)
first=node;
}
}
}
void main(){
myclass d;
d.Get();
}
</prev>
zahraZa 19-Aug-10 16:24pm View    
Reason for my vote of 3
useful