Wednesday, November 6
Special Diamonds Continued -- Usman Sherry
(Continued From Special Diamonds Part 1)
Part 2;
Here will use 2 loops inside one loop so that it is easy to print shape in less loops and coding;
It is simple because the loop we used for triangle in first page is going to be repeated in this loop only we will change the size alignment of shapes upside down;
int i,j,k,rows,size1,size2;cin<<rows;size1 [as described before you have to choose sequence of shapes so ]size2 [there are two options size1=1 and size2=rows /// or size2=rows and size1=1]do{ j=size1;do{cout<<”required character”;j--;} while (j < size);size1 ?? ; //here you define corresponding proceeding sizek=size2;do{cout<<”required character”;k--;} while (j < size);size2 ?? ; //here you define corresponding proceeding size}while(i<rows);I hope you have got the ideado{ //the main loopdo{ //corresponding first shape}whiledo{ //corresponding second shape}while}whileAnd in case of diamond you have to detect central row and print same size pyramid upside and then same size pyramid downsideTo detect central row รจ total rows / 2 = central row -1 //do not use this in codei.e. central row=(total rows/2 +1); //use this in code to detect central rowin this way you can print first part then print single row of size of central row then print second part so that the both main loops will have same size and almost same coding;first main loopcentral rowlast main loop
Sure
ReplyDeleteOy satianas ho gya iska yara.. next time me khud hi kr lun ga jesy bhi hua
ReplyDelete:D please sir, word ke bajaye visual studio use kerna, word saar icheezain kharab ker deta hai :P
ReplyDeleteto edit kar lain na :P
ReplyDeleteyaar he sent me a word file, us sey copy paste mai saar aproblem hua :P
ReplyDeleteye code ko kia hua ?
ReplyDelete