Site Navigation

Home
 
My Programs
 

     C# Classes

     VB 6.0 Programs

     C Programs

     C Games

Articles

My Blog

Page for Classmates

Programs by Others

Programming Problems

     Software Competitions


Programming Forum

Sign my Guestbook

View my Guestbook

Email me

 

International Software Competition 90

Competition Trial Run

National Computer Board Singapore

11 December 1990

 

Program 1

Pattern of Triangles

A pattern is constructed by stacking up 3 basic triangles formed with stars. The figure below shows each basic triangle having 3 layers of stars:

 

        *
       ***

      *****

     *     *

    ***   ***

   ***** *****

 

Write a program to display on a cleared screen a similar pattern with the given number of layers ranging from 2 to 10.

 

SAMPLE DATA

10 DATA 4

 

SAMPLE OUTPUT

        *
       ***

      *****
     *******

    *       *

   ***     ***

  *****   *****

 ******* *******

 

Program 2

Mean & S.D.

Write a program to read a series of marks in the range of 0 to 100. The series of marks is terminated by the number -1. Your program should then print the Average (Arithmetic Mean) and the S.D. (Standard Deviation). The answers should be correct to 1 decimal place. The formula for calculating the S.D. is as follows:

 

 

Where X sum of the squares of the individual marks; Y = sum of the marks;

N = the number of the marks in the series.

 

SAMPLE DATA

10 DATA 59, 90, 81, 32, 75, 63, 51, 43, 15, 66, 73, 87, 54, 93, 89, 62, -l

 

SAMPLE OUTPUT

AVERAGE = 64.6

S.D. = 21.4

 

Program 3

Weighted Number

You are given two 7-digit positive integers. Write a program to calculate and print out the sum of the products of each pair of digits occupying the same position in the two numbers. For example, given 1234567 and 2357531, the sum of the products of corresponding digits is

1x2 + 2x3 + 3x5 + 4x7 + 5x5 + 6x3 + 7x1 = 101.

 

SAMPLE DATA

10 DATA 1027589, 2357953

 

SAMPLE OUTPUT

ANSWER = 173

 

Program 4

The Magic Number 6174

An interesting sequence of numbers can be generated using any given four-digit number using this procedure:

First arrange the digits of the given number in ascending order. Next arrange the same digits in descending order. Then find the difference between the two arranged numbers. Use this as the next number the sequence.

For example, a given four-digit number 3087, generates a sequence of 3087, 8352, 6174, 6174, ... as shown below.

n(0) = 3087

n(1) = 8730 0378 = 8352

n(2) = 8532 2358 = 6174

n(3) = 7641 1467 = 6174

n(4) = 7641 1467 = 6174

It is known that for any four-digit positive number n(0) whose digits are not all the same, the process will generate the number 6174 in fewer than seven iterations.

You are to write a program that will read in a four-digit positive number whose digits are all not the same, and perform the process until the number 6174 is derived. Your program must be able to print the process as given in the sample output in which all the numbers in computation are printed out in four-digit form including leading zeros (if any).

 

SAMPLE DATA

10 DATA 2000

 

SAMPLE OUTPUT

n(0) = 2000

n(1) = 2000 - 0002 = 1998

n(2) = 9981 - 1899 = 8082

n(3) = 8820 - 0288 = 8532

n(4) = 8532 - 2358 = 6174