简单打印abcd组合

来源:互联网 发布:众阳软件 编辑:程序博客网 时间:2024/05/16 07:36

 #include<iostream>
using namespace std;

void find(string *p);

int main()
{
 string  a = "abcd" ;
 
 char temp;
 int len = a.length();
 
 for(int i = 0; i <len; i++)
 {  
  find(&a);
  temp = a[0];
  int j = 0;
  while(j<3)
  {
   a[j] = a[j+1];
   j++;
  }
  a[len-1] = temp;
  a[len] = '/0';
  
 }
 return 0;
}

void find(string *q)
{
    const char *p = const_cast<char *>(q->c_str());
 while(*p != '/0')
 {
  cout << p << "  ";
  p++;
  cout <<endl; 
 }
}

 

原创粉丝点击