Суббота, 20.04.2024, 19:13
Приветствую Вас Гость | RSS
Меню сайта
Вход на сайт
Поиск
Календарь
«  Апрель 2024  »
ПнВтСрЧтПтСбВс
1234567
891011121314
15161718192021
22232425262728
2930

An integer number is said to be a perfect number if its factors, including 1 (but not the number itself), sum to the number. For example, 6 is a perfect number because 6 = 1 + 2 + 3. Write a function isPerfect that determines whether parameter number is a perfect number. Use this function in a program that determines and prints all the perfect numbers between 1 and 1000. Print the factors of each perfect number to confirm that the number is indeed perfect. Challenge the power of your computer by testing numbers much larger than 1000.

Целое число называют совершенным, если сумма его делителей, включая 1 (но не само число), равна этому числу. Например, 6 является совершенным числом, поскольку  6 = 1 + 2 + 3. Напишите функцию isPerfect. которая определяет, является ли ее параметр совершенным числом. Используйте эту функцию в ... Читать дальше »

Категория: C (задачи) | Просмотров: 269 | Добавил: alex | Дата: 25.06.2018

Write a function that returns the smallest of three floating-point numbers.

Напишите функцию, которая возвращает наименьшее число из трех чисел с плавающей точкой.

# include <stdio.h>

float isMinimum(float, float, float);

int main()
{
    float i1, i2, i3;
    printf("%s", "Enter three floating-point numbers:");
    scanf("%f%f%f", &i1, &i2, &i3);

    printf("%.2f", isMinimum(i1, i2, i3));
}

float isMinimum( float a, float b, float c)
{
    float min;

    if(a < b)
        min = a;
 & ... Читать дальше »

Категория: C (задачи) | Просмотров: 234 | Добавил: alex | Дата: 25.06.2018

Implement the following integer functions:

a) Function toCelsius returns the Celsius equivalent of a Fahrenheit temperature.

b) Function toFahrenheit returns the Fahrenheit equivalent of a Celsius temperature.

c) Use these functions to write a program that prints charts showing the Fahrenheit equivalents of all Celsius temperatures from 0 to 100 degrees, and the Celsius equivalents of all Fahrenheit temperatures from 32 to 212 degrees. Print the outputs in a tabular format that minimizes the number of lines of output while remaining readable.< ... Читать дальше »

Категория: C (задачи) | Просмотров: 265 | Добавил: alex | Дата: 25.06.2018

Write a function that takes the time as three integer arguments (for hours, minutes, and seconds) and returns the number of seconds since the last time the clock “struck 12.” Use this function to calculate the amount of time in seconds between two times, both of which are within one 12-hour cycle of the clock.

 

Напишите функцию, которая получает время в качестве трех целых аргументов (часы, минуты, секунды) и возвращает число секунд с момента, когда часы «пробили 12». Используйте эту функцию для вычисления промежутка времени в секундах между двумя моментами, которые лежат внутри одного и того же 12-ти часового круга.

... Читать дальше »

Категория: C (задачи) | Просмотров: 323 | Добавил: alex | Дата: 25.06.2018

Write program segments that accomplish each of the following:

a) Calculate the integer part of the quotient when integer a is divided by integer b.

b) Calculate the integer remainder when integer a is divided by integer b.

c) Use the program pieces developed in a) and b) to write a function that inputs an integer between 1 and 32767 and prints it as a series of digits, with two spaces between each digit. For example, the integer 4562 should be printed as:

... Читать дальше »

Категория: C (задачи) | Просмотров: 289 | Добавил: alex | Дата: 24.06.2018

Use techniques similar to those developed in Exercises Square of Asterisks, Displaying a Square of Any Character to produce a program that graphs a wide range of shapes.

 

Используйте методику, аналогичную развитой в упражнениях Square of Asterisks, Displaying a Square of Any Character, для создания программы, которая рисует разнообразные фигуры.

#include <stdio.h>

void isSquare( char*);
void isRectangle( char*);
void isTriangle( char*);

int main()
{
    int var;
    char* fillCharacter;

    printf("%s", ... Читать дальше »

Категория: C (задачи) | Просмотров: 276 | Добавил: alex | Дата: 24.06.2018

Modify the function created in Exercise "Square of Asterisks" to form the square out of whatever character is contained in character parameter fillCharacter. Thus if side is 5 and fillCharacter is “#”, then this function should print

 

Измените функцию, созданную в задаче "Square of Asterisks" таким образом, чтобы она формировала квадрат для любых символов, содержащихся в символьном параметре fillCharacter. Например, если side равно 5, то функция выведет следующее:

#####

... Читать дальше »

Категория: C (задачи) | Просмотров: 284 | Добавил: alex | Дата: 23.06.2018

Write a function that displays a solid square of asterisks whose side is specified in integer parameter side. For example, if side is 4, the function displays.

Напишите функцию, которая выводит у левой границы экрана сплошной квадрат из символов *, сторона которого определяется целым параметром side. Например, если side равно 4, функция выведет следующее изображение:

****

****

****

****

#include <stdio.h>

void isSquare(int);

int main()
{
    int asterisks;
    puts("Enter asterisks:");
    scanf("%d", &asterisks);
    
    isSquare(asterisks);
}

void isSquare(int ast)
{
    for(int i = 1; i <= ast; i ++)
    {
        for(int j = 1; j <= ast; j ++)
        {
        & ... Читать дальше »

Категория: C (задачи) | Просмотров: 358 | Добавил: alex | Дата: 23.06.2018

Write a program that inputs a series of integers and passes them one at a time to function isEven, which uses the remainder operator to determine whether an integer is even. The function should take an integer argument and return 1 if the integer is even and 0 otherwise.

Напишите программу, которая вводит последовательность целых чисел и передает их по одному функции isEven, которая использует операцию деления по модулю, чтобы определить, является ли целое четным. Функция должна получать один аргумент и возвращать 1, если целое четно, и 0 в противном случае.

#include <stdio.h>

int isEven(int);

int main()
{
    int number;

    puts("Enter number:(Exit: 0)");
    scanf("%d", &number);

    while(number != 0)
    {
        if(isEven(number) == 1)
      ... Читать дальше »

Категория: C (задачи) | Просмотров: 273 | Добавил: alex | Дата: 23.06.2018

Write a function isMultiple that determines for a pair of integers whether the second integer is a multiple of the first. The function should take two integer arguments and return 1 (true) if the second is a multiple of the first, and 0 (false) otherwise. Use this function in a program that inputs a series of pairs of integers.

Напишите функцию isMultiple для двух целых, которая передает, кратно ли второе число первому. Функция должна получать два целых аргумента и возвращать 1(true), если второе число кратно первому, и 0(false) в противном случае. Используйте эту функцию в программе, которая вводит серию пар целых чисел.

#include <stdio.h>
#include <stdbool.h>

bool isMultiple(int, int);
int main()
{
    int integer1, integer2;
    puts("Enter integer1(enter - 0)");
    scanf("%d", &integer1);
    
     ... Читать дальше »

Категория: C (задачи) | Просмотров: 269 | Добавил: alex | Дата: 23.06.2018

1 2 3 ... 11 12 »