help me...give me suggestions...==

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
[#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;
int weight_table();
int Redundancy();
int store(int,char);
int cnt = 0;//total char
int weight[126]={0};//weight for each char
int Rweight[126]={0};
char function[126]={0};//store ascenting char
char Fstr[]={0};//store char entered
char secondF[]={0};
int Rearrange();
int cnt2 =0; 
int main(){
	char ch;
	int ref=0;
restart:	cout<<"Please enter a sentence(Put '.' at the end of sentence): ";
back:		cin>>ch;
			cnt++;//total charactes in a sentence.
			store(cnt,ch);
			if (ch != '.') goto back;
			weight_table();
		for(int i=0; i<=cnt; i++){
			cout<<"Weight of "<<"'"<<Fstr[i]<<"'"<<" are "<<weight[i]<<'\n';
			}
			Redundancy();
			Rearrange();
	cout<<"Total characters are ="<<cnt<<"\n\n";
goto restart;
return 0;
}
int store(int cnt, char ref){
	Fstr[cnt]= ref;
	
	return 0;
}
int Redundancy(){
	sort(Fstr,Fstr+cnt);//sort it before unique_copy inorder to elimate duplicated characters
	char *rr = unique_copy(Fstr,Fstr+cnt,function);//unique_copy(start,end,location)
	*rr=0;//truccate buffer
	for (int i=1; i<=cnt;i++){
		if(int(function[i])!=0){//print out characters.initially,"function[]"is fillup with 0's.
			cout<<"sequent2 "<< function[i] <<'\n';//PROBLEM!:"."does not print out
			}
	}
	cnt2 = (int) count(function,function+126,0);//cal num of '0'in function which are not occupied
	cout<<"num of zero's are "<<cnt2<<'\n';
return 0;
}
int weight_table(){
	for(int i=1; i<=cnt;i++){//evaluting weight of characters
		for(int j=1;j<=cnt;j++){
			if(int(Fstr[i])-int(Fstr[j]) == 0) weight[i] = weight[i]+1;
		}
	}
	return 0;
}
int Rearrange(){
	for (int i=1;i<=126-cnt2;i++){
		for(int j=1;j<=cnt;j++)
			if (int(function[i])-int(secondF[j])==0) Rweight[i]=weight[j];
		}
	return 0;
}

]

//i have working on it many days, but still not satisfy....
//my problem is i need to eliminate the redundant characters(run it u will see)...any 1 any suggestions? thx...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;
int weight_table();
int Redundancy();
int store(int,char);
int cnt = 0;//total char
int weight[126]={0};//weight for each char
int Rweight[126]={0};
char function[126]={0};//store ascenting char
char Fstr[]={0};//store char entered
char secondF[]={0};
int Rearrange();
int cnt2 =0; 

int NewWeight[256];

int main(){
	char ch;
	int ref=0;
restart:	cout<<"Please enter a sentence(Put '.' at the end of sentence): ";
back:		cin>>ch;
//			cnt++;//total charactes in a sentence.
//			store(cnt,ch);
			NewWeight[ch]++;
			if (ch != '.') goto back;
//			weight_table();
		for(int i=0; i<256; i++){
			if(NewWeight[i]){
				cout<<"Weight of "<<"'"<<(char)i<<"'"<<" are "<<NewWeight[i]<<'\n';
			}
		}
		cnt = 0;
		for(i=0; i<256; i++){
			if(NewWeight[i]){
				cout<<"sequent2 "<<(char)i<<'\n';
				cnt++;
			}
		}
//			Redundancy();
//			Rearrange();

	cout<<"Total characters are ="<<cnt<<"\n\n";
goto restart;
return 0;
}
int store(int cnt, char ref){
	Fstr[cnt]= ref;
	
	return 0;
}
int Redundancy(){
	sort(Fstr,Fstr+cnt);//sort it before unique_copy inorder to elimate duplicated characters
	char *rr = unique_copy(Fstr,Fstr+cnt,function);//unique_copy(start,end,location)
	*rr=0;//truccate buffer
	for (int i=1; i<=cnt;i++){
		if(int(function[i])!=0){//print out characters.initially,"function[]"is fillup with 0's.
			cout<<"sequent2 "<< function[i] <<'\n';//PROBLEM!:"."does not print out
			}
	}
	cnt2 = (int) count(function,function+126,0);//cal num of '0'in function which are not occupied
	cout<<"num of zero's are "<<cnt2<<'\n';
return 0;
}
int weight_table(){
	for(int i=1; i<=cnt;i++){//evaluting weight of characters
		for(int j=1;j<=cnt;j++){
			if(int(Fstr[i])-int(Fstr[j]) == 0) weight[i] = weight[i]+1;
		}
	}
	return 0;
}
int Rearrange(){
	for (int i=1;i<=126-cnt2;i++){
		for(int j=1;j<=cnt;j++)
			if (int(function[i])-int(secondF[j])==0) Rweight[i]=weight[j];
		}
	return 0;
}


Is the result above you want? pls run it.
Great!!!.flaverli....this is very useful to me...really thanks u a lot...
u let me know more ab the C++!
u let me move more faster now....really thanks ur help...
Topic archived. No new replies allowed.