1438 - CS I2P 2018 Lee HW5 Scoreboard

Time

2018/04/17 15:30:00 2018/06/25 00:00:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
10806 Prime number calculator (function)
11896 Check Palindrome (function)

10806 - Prime number calculator (function)   

Description

Given a range, you need to count the number of prime numbers in the range.

Note that "1" is not the prime number.



For example:

The range is 1~10

You need to print 4.

Beacuse of there are 4 numbers (2, 3, 5, 7 are the prime numbers) in the range 1~10.


Note that

1.      This problem involves three files.

  • function.h: Function definition of numPrime.
  • function.cpp: Function describe of numPrime.
  • main.cpp: A driver program to test your implementation.

You will be provided with main.cpp and function.h, and asked to implement function.cpp.

2.     For OJ submission:

       Step 1. Submit only your function.cpp into the submission block. (Please choose c++ 11 compiler

       Step 2. Check the results and debug your program if necessary.

function.h

#ifndef FUNCTION_H

#define FUNCTION_H

int numPrime(int start, int end);

#endif

main.cpp

#include <stdio.h>

#include "function.h"

int main(){

    int start, end, num;

    scanf("%d %d", &start, &end);

    num = numPrime(start, end);

    printf("%d", num);

    return 0;

}

Input

Given the start and end of the range: S E.

Fisrt number S is the start number of the range.

Second number E is the end number of the range.

And the range limit is 1 <= S <= E <= 5000.

For example:

when input is "1 10", it means the range is 1 to 10.

Output

Count the number of prime numbers in the range. 

Note that you do not need to print '\n' at the end of the output.

Sample Input  Download

Sample Output  Download

Partial Judge Code

10806.cpp

Partial Judge Header

10806.h

Tags

10401HW6



Discuss




11896 - Check Palindrome (function)   

Description

Palindrome is a string that is identical to its reverse, like "level" or "aba". Given a string, check it is palindrome or not.

You are to check all possibile substring (the length of substring is greater than or equal to 2).

NOTE: In the partial code, the function has three parameters: the pointer of the input string, the start position, and the end position.

The range of each substring is from start position to end position (contain the element in the end position).

Input

The input only contains one string. The length of the string is less than 1000.

Output

If the substring is palindrome, print "Yes\n".

If the substring is not palindrome, print "No\n".

Sample Input  Download

Sample Output  Download

Partial Judge Code

11896.c

Partial Judge Header

11896.h

Tags




Discuss