// starbubble.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <string>
using namespace std;
int bubble(char* str);
int _tmain(int argc, _TCHAR* argv[])
{
char strArr[] = {'1','a','*','*','b','c','d','*','*','\0'};
string str = "1d**ddd**";
int starNumber = bubble(strArr);
printf("star number is %d", starNumber);
printf("result str is %s", strArr);
return 0;
}
int bubble(char* str)
{
int len = strlen(str);
int starcount = 0;
for(int i = 0; i < len-1; i++)
{
for(int j = 1; j < len ; j++)
{
char temp = str[j-1];
if(str[j] == '*')
{
str[j-1] = str[j];
str[j] = temp;
if(i == 0)
{
starcount++;
}
}
}
}
return starcount;
}