Essays.club - Получите бесплатные рефераты, курсовые работы и научные статьи
Поиск

Програмування на мові С

Автор:   •  Ноябрь 30, 2022  •  Лабораторная работа  •  583 Слов (3 Страниц)  •  79 Просмотры

Страница 1 из 3

Вінницький національний технічний університет

Факультет інтелектуальних інформаційних технологій та автоматизації Кафедра «Комп’ютерних наук»

Лабораторна робота №2

З дисципліни «Алгоритмізація та програмування»

Тема: «Програмування на мові С»

Виконав студен 5КН-22б Столяр П.М. Перевірив: Краєвський В.О.

Вінниця 2022

 

Мета: виконати problem set 1

Код «hello »

#include <stdio.h> 

#include <cs50.h> 

int main(void) 

{ 

//виводимо привіт, світ 

printf("hello, world\n"); 

//запит на ім'я користувача 

string name = get_string("What is your name? "); //вивести hello та the name 

printf("hello, %s\n", name); 

} 

Оцінка «hello» [pic 1]

 

 Код «this version of Mario if feeling less comfortable»

#include <cs50.h> 

#include <stdio.h> 

int main(void) 

{ 

//оголошуємо int змінну height 

int height; 

do 

{ 

//запитуємо у коритсувача висоту 

height = get_int("Height: "); 

} 

//визначаємо, що висота не повинна бути меньше 1 або  більше 8 

while (height < 1 || height > 8); 

//виводимо новий рядок як row 

for (int row = 0; row < height; row++) 

{ 

//виводимо пусті рядки,що зроблять наші сходинки  справа 

for (int space = height - row - 1; space > 0;  space--) 

{ 

printf(" "); 

} 

//виводимо # 

for (int hash = 0; hash < row + 1; hash++) 

{ 

printf("#"); 

} 

printf("\n"); 

} 

}

Оцінка «this version of Mario if feeling less comfortable» [pic 2]

Код «Cash if feeling less comfortable»

 

#include <cs50.h> 

#include <stdio.h> 

int get_cents(void); 

int calculate_quarters(int cents); 

int calculate_dimes(int cents); 

int calculate_nickels(int cents); 

int calculate_pennies(int cents); 

int main(void) 

{ 

// Ask how many cents the customer is owed 

int cents = get_cents(); 

// Calculate the number of quarters to give the  customer 

int quarters = calculate_quarters(cents); 

cents = cents - quarters * 25; 

// Calculate the number of dimes to give the customer int dimes = calculate_dimes(cents); 

cents = cents - dimes * 10; 

// Calculate the number of nickels to give the  customer

...

Скачать:   txt (4.8 Kb)   pdf (128.1 Kb)   docx (18.5 Kb)  
Продолжить читать еще 2 страниц(ы) »
Доступно только на Essays.club