项目

1.
学号2018*****7229
姓名 郭子郛
仓库 https://gitee.com/nsise/level-18-personal-project/commits/master
2.                                                 预计时间                        实际需要时间
搭建配置开发环境                          2小时                           已经有此软件
在码云中获取作业仓库                    一个小时                          10分钟
完成作业要求实现的程序                    两天                         半天(没写完整)
为程序撰写单元测试                         半天                            三个小时
对程序进行效能分析                         半天                              俩小时

3.

1.将字符串转换为字符串数组;
2.遍历数组放置linkedhashmap,利用map的key唯一性
3.遍历map,利用stringBuilde拼接字符串输出;

4.

  1. 定义一个测试类(测试用例)
  2. 定义测试方法:可以独立运行
  3. 给方法加@Test
  4. 导入Junit依赖环境 add to classpath
  5. 使用断言操作来处理结果

5.JProfiler对程序进行效能分析

 1.通过引用分析该对象

  2.通过创建分析该对象

代码优化和算法同时优化

代码  实现功能

 

int main() {
    int counts[26], i;
    char c;
    FILE* fp = fopen("input.txt", "r");
    FILE* op = fopen("output.txt", "w");
    memset(counts, 0, sizeof(counts));
    while (fscanf(fp, "%c", &c) == 1) {
        baiif (isalpha(c)) {
            counts[tolower(c) - 'a']++;
        }
    }
    for (i = 0; i < 26; i++) {
        printf("%c: %d\n", i + 'a', counts[i]);
        fprintf(op, "%c: %d\n", i + 'a', counts[i]);
    }
    fclose(fp);
    fclose(op);
}

 

 


public static void pr(String x){
7 System.out.print(x);
8 }
9
10 public static boolean isBigFirst(String str){
11 char []br = str.toCharArray();
12 if(br[0]>='A'&&br[0]<='Z')
13 return true;
14 else
15 return false;
16 }
1
18 public static boolean isSmallFirst(String str){
19 char []br = str.toCharArray();
20 if(br[0]>='a'&&br[0]<='z')
21 return true;
22 else
23 return false;
24 }
26 public static String ChangeToSmall(String str){
27 StringBuffer sb = new StringBuffer(str);
28 char s = sb.charAt(0);
29 if(!StringBasic.isBigFirst(str))
30 return "\0";
31 sb.delete(0,1);
32 s = (char)(s-'S'+'s');
33 sb.insert(0,s);
34 return sb.toString();
35 }
37 public static String ToSmall(String x){
38 return x.toLowerCase();
39 }
45 public static String DeleteString(String x){
46 x = x.replace(".","");
47 x = x.replace(",","");
48 x = x.replace("!","");
49 x = x.replace("?","");
50 x = x.replace("\"","");
51 x = x.replace("-","");
52 return x;
53 }
59 }
4 public class StringManager {
7 private String string;
9 private int num;
12 public void setString(String str){
13 string = str;
14 }
15 public String getString(){
16 return string;
17 }
19 public void setNum(int nums){
20 num = nums;
21 }
22 public int getNum(){
23 return num;
24 }
26 public void add(){
27 num++;
28 }
29 public void add(int n){
30 num = num + n;
31 }
33 public void Print(){
34 System.out.println(string+" : "+num);
35 }

stopwords.txt

 

int my_strlen(char a[]);
void Find(char *a,char *find,int k);
void KG(char a[]);
int main()
{
int i,j,k;
char a[M],find[M];
scanf("%[^\n]",a);
printf(""a", "it", "the", "and", "this"");
scanf("%s",find);
k=my_strlen(find);
Find(a,find,k);
KG(a);
system("pause");
return 0;
}

string w;
int i=0;
int j=str.find(" ");
while(j!=-1){
w=str.substr(i,j-i);
words.push_back(w);
i=j+1;
j=str.find(" ",i);
}
if(i<str.length()-1){
w=str.substr(i);
words.push_back(w);
}
}
int main(){
string str="The following code computes the intersection of two arrays";
vector<string> words;
solve(str,words);
cout<<"所有的单词:"<<endl;
vector<string>::iterator it;
for(it=words.begin();it!=words.end();++it){
cout<<" "<<*it<<endl;
}
return 0;

 

    

posted @ 2020-10-09 20:15  新奇luna  阅读(123)  评论(0编辑  收藏  举报