Пятница, 13.06.2025, 16:38
Приветствую Вас Гость | RSS
Меню сайта
Вход на сайт
Поиск
Календарь
«  Июнь 2025  »
Пн Вт Ср Чт Пт Сб Вс
      1
2345678
9101112131415
16171819202122
23242526272829
30
Статистика

Главная » C (задачи)

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

#define SUITS 4
#define FACES 13
#define CARDS 52
//тасовать карты
void shuffle(unsigned int wDeck[][FACES]);
//раздать карты игрокам
void deal(unsigned int wDeck[][FACES], unsigned int wPlayer[][2], const char *wFace[], const char *wSuit[], unsigned int start,  unsigned int finish);
//оценка карт игроков
void mark(unsigned int wPlayer1[][2], unsigned int wPlayer2[][2], const char *wFace[], const  char *wSuit[], unsigned int *nominal1, unsigned int *nominal2);

int  printRating(unsigned int*, unsigned int*);//печать результата оценивания карт
int fPriority(unsigned int wPlayer[][2], const char *wFace[],  const char *wSuit[], unsigned int *nominal);//определение приоритета карт игроков
void  sort(unsigned int wPlayer[][2],  const char *wFace[], const  char *wSuit[]);//сортировка карт, котор ... Читать дальше »

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

#include <stdio.h>
#define SIZE 100
#define SIZE2 8

int testPalindrome(char str[], int start, int end);

int main(void)
{
    char string1[SIZE];
    char string[SIZE];
    char p[SIZE2] = {' ', ',', '.', '!', '?', ':', '-','\0'};
    int n = 0;
    int i, count = 0;

    int result;
    
    printf("%s","Enter a string:\n");
    fgets(string1, SIZE, stdin);
    fflush(stdin);
    
    
   
    for( i = 0; i < SIZE && string1[i] != '\0'; i++)
    {
        for (int j = 0; j < SIZE2 && ... Читать дальше »

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

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 (задачи) | Просмотров: 301 | Добавил: 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 (задачи) | Просмотров: 265 | Добавил: 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 (задачи) | Просмотров: 301 | Добавил: 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 (задачи) | Просмотров: 375 | Добавил: 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 (задачи) | Просмотров: 330 | Добавил: 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 (задачи) | Просмотров: 310 | Добавил: 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 (задачи) | Просмотров: 321 | Добавил: 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 (задачи) | Просмотров: 403 | Добавил: alex | Дата: 23.06.2018

1 2 »