-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocess2
More file actions
71 lines (68 loc) · 1.62 KB
/
Copy pathprocess2
File metadata and controls
71 lines (68 loc) · 1.62 KB
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
#include<iostream>
#include<string>
#include<fstream>
#include<sstream>
#include<vector>
using namespace std;
string key_word[32]={
"auto","break","case","char","const","continue","default","double",
"do","else","enum","extern","float","for","goto","if","int","long",
"register","return","short","signed","sizeof","static","struct",
"switch","typedef","union","unsigned","void","volatile","while"
};
vector<int> Case_num;
int total_num=0;
int switch_num=0;
int case_num=0;
int ifelse_num=0;
int if_elseif_else_num=0;
int stack[1000]={0};
int top=-1;
int main(){
string File1, temp;
int Level;
cout << "Please enter the root of the file:" << endl;
cin >> File1;
cout << "Please enter the level to inquire:" << endl;
cout << "1--total" << endl;
cout << "2--switch-case" << endl;
cout << "3--if_else" << endl;
cout << "4--if_elseif_else" << endl;
cin >> Level;
ifstream myfile(File1.c_str());
int estimate_1(string x, string y);
void Level_12(string str);
void Level_34(string str);
while (getline(myfile, temp)){
istringstream is (temp);
string s;
if(Level >= 3){
Level_34(temp);
}
while(is >> s){
Level_12(s);
}
}
if(Level >= 1){
cout << "total num:" << total_num << endl;
}
if(Level >= 2){
cout << "switch num:" << switch_num << endl;
if(!Case_num.empty()){
Case_num.push_back(case_num);
}else{
Case_num.push_back(0);
}
cout << "case_num :";
for (int i = 1; i <= switch_num; i++){
cout << Case_num[i] << " ";
}
cout << endl;
}
if(Level >= 3){
cout << "if-else num:" << ifelse_num << endl;
}
if(Level >= 4){
cout << "if-elseif-else num:" << if_elseif_else_num;
}
}