Wednesday, December 11
sorting of character arrays based on first character only
A code for Sir Saeed
/** * code by http://CppQA.blogspot.com * sorting of character arrays based on first character only * C++ */ #include <iostream> #include <string.h> using namespace std; int main() { char countries[5][15] = {"Pakistan","India","Afghanistan","Iran","China"}; for(int i=0;i<5;i++) { for(int j=0;j<5-1;j++) { if(countries[i][0] < countries[j][0]) {//swaping char temp[15]; strcpy(temp,countries[i]); strcpy(countries[i],countries[j]); strcpy(countries[j],temp); } } } //print for(int i=0;i<5;i++)cout<<countries[i]<<endl; return 0; }
i think it should be i-1
ReplyDeleteyou are right, it should be i-1 for bubble sort. good job
ReplyDeletethats my child :D
ReplyDeletethats my child ,
ReplyDeletesalo kia drama hai yeh :D
ReplyDelete:D :D pata nae kon loag hain ye, i might be able to see their emails ids still :P
ReplyDelete