Chapter 1 and II assignments

Source: Internet
Author: User
Tags mercurial using git

Chapter 1 homework:

1. Four arithmetic generators (Python)

_ Author _ = 'doris'

 

From Random import *

 

Def createanexpression ():

Beginnum = 0

Endnum= 100

A = randint (beginnum, endnum)

B = randint (beginnum, endnum)

C = randint (beginnum, endnum)

D = randint (beginnum, endnum)

 

Opchoice = ("+ ","-","*","/")

OP1 = choice (opchoice)

OP2 = choice (opchoice)

OP3 = choice (opchoice)

 

Exp = STR (A) + OP1 + STR (B) + OP2 + STR (c) + OP3 + STR (d)

Return exp

 

 

 

If _ name _ = "_ main __":

Num = 50

For I in range (0, 50 ):

Print createanexpression ()

 

 

 

2. The "special" Phenomenon of the software:

A. FLASHBACK: when using some game software, there may be a crash due to insufficient memory, and the user experience is poor without notice.

B. Host freezing: some software versions may experience machine freezing, such as Baidu browser, which has been criticized. The reason may be that the new version is not functional properly tested.

C. Near-death: only the first version of the software has been released, and the bug feedback has not been fixed. The possible cause is that the developer does not perform maintenance and is often used in school projects.

3. Currently, popular source program version management software include Microsoft TFS, GitHub, SVN, HG/mercurial.

 

TFS: a collaborative development tool provided by Microsoft, centralized

Git: open-source version control tool with Distributed Control

SVN: centralized control

Hg: Distributed Control

 

 

Advantages

Disadvantages

TFS

  1. Multiple features. In addition to version management, it provides demand management, Bug Management, and deployment management.
  2. It has the lock function and is suitable for large projects to avoid code submission and change conflicts.
  3. Version Management is too redundant.
  4. Online code management
  5. At the cost of personal use efficiency
 

Git

  1. Fast
  2. Supporting upstream-downstream collaborative development
  3. Local submission + code library submission
  4. Many managed servers
  5. It is difficult to get started with many Command Parameters
  6. No comprehensive access permission Control
  7. The subtree cannot be moved out independently.
  8. Version is too hard to remember
 

SVN

  1. Unified version number,
  2. Support relay data management
  3. Automatic File System Monitoring
  4. You can checkout a single subtree.
  5. Easy to operate
  6. It is difficult to migrate new versions of upstream Software
  7. Slow speed
 

HG/mercurial

  1. Linearly increasing numeric version number
  2. Easy to operate
  3. Fast
  4. Branch not supported
  5. Not prompted when the speed is too slow
 

 

Project management software:

TRAC: an open-source application platform, including Wiki and problem tracking. Project management is based on the progress-oriented model and milestones. Python development requires environment support.

Bugzilla: A software customized for Unix tracing systems. It manages the entire lifecycle of defects in software development, such as submission, repair, and closure.

Apple xcode: an integrated development environment provided by Apple to developers for creating ios x and iOS applications. Unified user interface design, coding, testing, and debugging are all completed in a simple window, with extremely fast Compilation speed.

 

4. software Engineering does not teach people who do not write programs to develop software, but provides a scientific and effective development idea, development philosophy, development model, and development process, this allows the development team to work more effectively and provide more reliable and excellent products.

 

5. Tianjin University has two Majors: software engineering and computer science:

Computer Science focuses on science, that is, academics, on the specific direction of mathematics and computers, theory, graphics and images, parallel computing, and hardware development.

Software Engineering focuses on software development, such as language courses, design patterns, operating systems, demand analysis, software architecture, UML modeling language, and software project management.

The main difference between the two lies in that software engineering involves human activities, considering what the software is, how the team is organized, how the software is completed, and how it is better developed; computer Science, however, does not directly consider engineering issues from a theoretical perspective.

A joke is: "The softwares come out, all of them are coders; the coders come out of China, 90% yards of farmers, and 10% electricians ".

 

6. This approach is inappropriate and does not conform to the ethics and is not covered in the scope of "Software Engineering" research.

Software Engineering has clear professional ethics requirements. Only when the software is safe, compliant with the specifications, passes tests, does not reduce the quality of life, does not infringe privacy, and does not cause environmental harm, we recognize this software and cannot seek its own interests at the expense of others. Programs or software have no ethical or ethical constraints, but companies or programmers must have their own professional ethics requirements and qualities. Programmers cannot control their skills without rules.

 

7. "Chinese programming" is not a weapon to improve programming efficiency. First, there is no mature compiling environment. Second, repeated switching of Chinese and English input may cause imperceptible bugs. Third, English is widely used as a recognized language for programming, after the use of Chinese programming, a large number of open-source projects are difficult to maintain, resulting in barriers to communication. Fourth, there are many Chinese Language ambiguities and a series of customized regulations can be applied.

 

 

8. created.

 

9. Problem: The feasibility of peer programming in time operations

Compared with incremental development, agile processes require too much personal competence of Members. Is it a mainstream development method?

In current development, try to avoid too many documents and check whether TFs functions are too complex.

Solutions for frequent job hopping by programmers

In the company's actual development process, the use of complete software engineering ideas for development, time, economic can bear

 

10. A. Completed

B. "Mobile Iot system": The project uses mobile phones and other mobile devices to control household appliances. As a competition project, the project has achieved good results but has not been pushed to the market. Development and maintenance are not performed after the competition. The project source code and documentation are still archived, but the Code has no remarks and the documentation is too simple, so the re-development cost is high.

Experience and Lessons: market promotion should be carried out for good software; detailed documentation and necessary remarks should be provided during the development process to facilitate the transfer to others for further development.

The suggestions for Learning Software Engineering well are: pay more attention to the industry information and understand new software engineering ideas; combine theory with practice, and try to use the concept of Software Engineering for development in actual development.

 

11. "Software": In 1958, Tukey's paper "the teaching of concrete mathematics" used the concept of software for the first time. 1953 Richard R. carhart used the word software in the memorandum

"Software Engineering": At the first Software Engineering Conference in 1968, NATO proposed the concept of software engineering for the first time.

Chapter 2 homework:

 

1. (1)

 

 

1 (2)Maxsum:

# Include <iostream>

 

Using namespace STD;

 

Intarraymaxsum (int * arr, int N)

{

Int sum = arr [0];

Inttmp = 0;

 

For (INTI = 0; I <n; I ++)

{

If (TMP <0)

TMP = arr [I];

Else

TMP + = arr [I];

If (sum <TMP)

Sum = TMP;

 

}

Return sum;

}

 

Int main ()

{

Intmyarr [100] = {1,-2, 3, 5,-1 };

Intnum = 5;

Intrlt = arraymaxsum (myarr, num );

Cout <rlt;

Return 0;

}

 

1. (3)Reverse word:

# Include <iostream>

# Include <cstring>

 

Using namespace STD;

 

Voidswapchar (char & A, char & B)

{

Chartmp = B;

B =;

A = TMP;

}

 

Voidsentenceswap (char * STR, intsbegin, intsend)

{

Int low = sbegin;

Int high = Send;

 

While (low

{

Swapchar (STR [low], STR [High]);

Low ++;

High --;

}

}

 

Voidreverseword (char STR [])

{

Intlen = strlen (STR );

 

Sentenceswap (STR, 0, len-1 );

 

Int S = 0;

Int e = 0;

 

For (INTI = 0; I <Len; I ++)

{

E = I;

If (STR [e] = '')

{

Sentenceswap (STR, S, E-1 );

S = e + 1;

}

If (E = len-1)

{

Sentenceswap (STR, S, e );

}

}

}

 

Int main ()

{

Charstr [] = "hosw are you ";

Reverseword (STR );

Cout <STR <Endl;

Return 0;

}

 

 

 

1. (4)Drag the mouseHello World:

Form1.cs:

 

Using system;

Usingsystem. Collections. Generic;

Usingsystem. componentmodel;

Usingsystem. Data;

Usingsystem. drawing;

Usingsystem. LINQ;

Usingsystem. text;

Usingsystem. Threading. tasks;

Usingsystem. Windows. forms;

 

Namespacedraglabel

{

Publicpartialclassform1: Form

{

Public form1 ()

{

Initializecomponent ();

}

 

Privatepointmouseoffset;

 

 

Privatevoid label=mouseup (Object sender, mouseeventargs E)

{

If (E. Button = mousebuttons. Left)

{

Pointmousepos = control. mouseposition;

Mousepos. offset (mouseoffset. X, mouseoffset. y );

(Control) sender). Location = (Control) sender). Parent. pointtoclient (mousepos );

}

}

 

Privatevoid label1_mousedown (Object sender, mouseeventargs E)

{

Mouseoffset = newpoint (-E. X,-E. y );

}

}

}

 

Namespacedraglabel

{

Partialclassform1

{

/// <Summary>

/// Required designer variables.

/// </Summary>

Privatesystem. componentmodel. icontainer components = NULL;

 

/// <Summary>

/// Clear all resources in use.

/// </Summary>

/// <Param name = "disposing"> If the managed resource should be released, the value is true; otherwise, the value is false. </Param>

Protectedoverrisponid dispose (bool disposing)

{

If (disposing & (components! = NULL ))

{

Components. Dispose ();

}

Base. Dispose (disposing );

}

 

# Region code generated by Windows Form Designer

 

/// <Summary>

/// The designer supports the required methods-do not

/// Use the code editor to modify the content of this method.

/// </Summary>

Privatevoidinitializecomponent ()

{

This. label1 = Newsystem. Windows. Forms. Label ();

This. suspendlayout ();

//

// Label1

//

This. label1.autosize = true;

This. label1.location = Newsystem. Drawing. Point (12, 26 );

This. label1.name = "label1 ";

This. label1.size = Newsystem. Drawing. Size (77, 12 );

This. label1.tabindex = 0;

This. label1.text = "Hello world! ";

This. label1.mousedown + = Newsystem. Windows. Forms. mouseeventhandler (label+mousedown );

This. label1.mouseup + = Newsystem. Windows. Forms. mouseeventhandler (label+mouseup );

 

//

// Form1

//

This. autoscaledimensions = Newsystem. Drawing. sizef (6f, 12f );

This. autoscalemode = system. Windows. Forms. autoscalemode. Font;

This. clientsize = Newsystem. Drawing. Size (284,261 );

This. Controls. Add (this. label1 );

This. Name = "form1 ";

This. Text = "form1 ";

This. resumelayout (false );

This. initialize mlayout ();

 

}

 

# Endregion

 

Privatesystem. Windows. Forms. Label label1;

 

}

}

 

 

 

 

 

1. (5). interpret

(1) the number to be searched by the Program: The number cannot be divisible by RG [k] and RG [k + 1] In the array, but can be divisible by all other numbers.

(2) First, the characteristics of RG are analyzed:

When n <= 15, N * 2 is also in the array, so n> 15.

The remaining numbers can be divided into 16 = 2*8, 18 = 2*9, 20 = 4*5, 22 = 2*11, 24 = 3*8, 26 = 2*13, 28 = 4*7, 30 = 2*15, but 16 is removed because 2 is the factor of 8 in 16 = 2*8.

In this way, the numbers of RG [k] and RG [k + 1] are 16 and 17.

The next step is to find the number that cannot be divided by 16 and 17, but can be divided by all the other numbers.

Remove all prime numbers 16 and 17 from 2 to 31: 2 3 5 7 11 13 19 23 29 31

The non-prime number can be obtained by multiplying the prime number as a factor, where 8 = 2*2*2, 25 = 5*5, 27 = 3*3*3, which is an exception.

Therefore, the minimum number is 2 ^ 3*3 ^ 3*5 ^ 2*7*11*13*19*23*29*31 =

2123581660200

(3) Estimated Time:

This program mainly includes a modulo operation and a judgment. If you enter the if statement, it also includes an addition operation, 1 ~ Two judgments and one value assignment operation.

Operations such as addition and judgment are performed in several clock cycles, and division and modulo operation are performed in dozens of clock cycles. In addition, the Division of 64-bit integers is slower than that of 32-bit integers.

We can assume that an operation requires 100 clock cycles. Therefore, a 4 GHz CPU can run 4*10 ^ 9/100 = 4*10 ^ 7 in 1 second, that is, 0.64 billion atomic operations, about 0.03 s.

Number of subsequent operations: the outer loop runs 2123581660200 times, and the inner loop depends on I. When I is an odd number, the inner can run up to 5 times to end; when I is an even number, it is about 10 times on average, and the total operation is 2*10 ^ 13 times.

Therefore, it takes 2*10 ^ 13/(4*10 ^ 7) * 0.03 = 6000 seconds, which is about 100 minutes.

(4) You can use Cuda for GPU acceleration to separate the division of each element in the array.

 

2. Efficiency Analysis

The major program design task is about three weeks, 4 hours a day, 15*4 = 60 hours.

The program volume is 1000 ~ 1500 loc.

Most of the assignments for this undergraduate course are personal projects. Therefore, fewer students are using source code management, and some of them are used to managing code using git.

There are about 3-5 independent students.

It shows that students tend to "pick up" when they encounter difficulties, rather than asking for help and completing the work by themselves. Secondly, they are not well prepared in time planning. It is often because they have not been well written for a long time, by the time of DDL, you can use others' jobs in a matter of time.

3. Replace arraylist with list, because arraylistz usually produces packing and unboxing operations when storing or retrieving value types, resulting in high performance consumption.

You can use the performance analysis tool to observe the time overhead of each sentence in the program and optimize the program.

Chapter 1 and II assignments

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.