Programming and algorithms Peking (a) the first week of test (Spring 2020)

001: Output the second integer

  • Total time limit:

    1000ms

  • Memory Limit:

    65536kB

  • description

    Three input integer, the integer output of the second input.

  • Entry

    Only one row, a total of three integers, separated by a space between integers. Is an integer 32-bit signed integer.

  • Export

    Only one line, an integer, the second integer is entered.

  • Sample input

    123 456 789

  • Sample Output

    456

#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	int a=0,b=0,c=0;
	scanf("%d %d %d",&a,&b,&c);
	printf("%d",b);
	return 0;
 } 

002: Character diamond

  • Total time limit:

    1000ms

  • Memory Limit:

    65536kB

  • description

    Given a character, it is configured with a diagonal length of 5 characters, tilted diamond.

  • Entry

    Enter only one line containing a character.

  • Export

    The character made of diamond.

  • Sample input

    *

  • Sample Output

      *
     ***
    *****
     ***
      *
    
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	char a;
	scanf("%c",&a);
	printf("  %c\n",a);
	printf(" %c%c%c\n",a,a,a);
	printf("%c%c%c%c%c\n",a,a,a,a,a);
	printf(" %c%c%c\n",a,a,a);
	printf("  %c\n",a);


	
	return 0;
 } 

003: printable ASCII code

  • Total time limit:

    1000ms

  • Memory Limit:

    65536kB

  • description

    One visible character other than a space (guaranteed use% c format specifier reads in the function scanf), the output of the ASCII string.

  • Entry

    A visible character other than spaces.

  • Export

    A decimal integer that is the ASCII character code.

  • Sample input

    A

  • Sample Output

    65

#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	char a;
	scanf("%c",&a);
	printf("%d",a);


	
	return 0;
 } 

004: printing characters

  • Total time limit:

    1000ms

  • Memory Limit:

    65536kB

  • description

    Enter an ASCII code corresponding to the output character.

  • Entry

    An integer, i.e., the ASCII codes of the characters to ensure that there is a corresponding visible characters.

  • Export

    Row contains the corresponding characters.

  • Sample input

    65

  • Sample Output

    A

#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	int a;
	scanf("%d",&a);
	printf("%c",a);

	return 0;
 } 

005: INTEGER type storage space

  • Total time limit:

    1000ms

  • Memory Limit:

    65536kB

  • description

    Each define a int, short type variable, and sequentially outputs them to the storage space (unit: bytes).

  • Entry

    no.

  • Export

    Line, two integers, namely, the size of the storage space two variables, separated by a space.

  • Sample input

    (无)

  • Sample Output

    (不提供)

  • prompt

    Use sizeof function can be a particular variable amount of storage space. For example: For x int variables, the sizeof (x) is 4, i.e., the memory space x 4 bytes.

#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	int a = 0;
	short c = 'a';
	printf("%d %d",sizeof(a),sizeof(c));
	return 0;
 } 

006: floating-point data type storage space

  • Total time limit:

    1000ms

  • Memory Limit:

    65536kB

  • description

    Each define a float, double type variable, and sequentially outputs them to the storage space (unit: bytes).

  • Entry

    no.

  • Export

    Line, two integers, namely, the size of the storage space two variables, separated by a space.

  • Sample input

    (无)

  • Sample Output

    (不提供)

#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	float a = 0.0;
	double c = 0.0;
	printf("%d %d",sizeof(a),sizeof(c));
	return 0;
 } 
Published 21 original articles · won praise 0 · Views 478

Guess you like

Origin blog.csdn.net/qq_39901722/article/details/104827166