Сравнить коммиты
Ничего общего в коммитах. 'main' и 'mainC' имеют совершенно разные истории.
@ -1,4 +0,0 @@
|
||||
/bin
|
||||
/obj
|
||||
project.layout
|
||||
project.depend
|
@ -0,0 +1,4 @@
|
||||
/Project.depend
|
||||
/bin
|
||||
/obj
|
||||
/Project.layout
|
@ -0,0 +1,40 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||
<CodeBlocks_project_file>
|
||||
<FileVersion major="1" minor="6" />
|
||||
<Project>
|
||||
<Option title="Project" />
|
||||
<Option pch_mode="2" />
|
||||
<Option compiler="gcc" />
|
||||
<Build>
|
||||
<Target title="Debug">
|
||||
<Option output="bin/Debug/Project" prefix_auto="1" extension_auto="1" />
|
||||
<Option object_output="obj/Debug/" />
|
||||
<Option type="1" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-g" />
|
||||
</Compiler>
|
||||
</Target>
|
||||
<Target title="Release">
|
||||
<Option output="bin/Release/Project" prefix_auto="1" extension_auto="1" />
|
||||
<Option object_output="obj/Release/" />
|
||||
<Option type="1" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-O2" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
</Linker>
|
||||
</Target>
|
||||
</Build>
|
||||
<Compiler>
|
||||
<Add option="-Wall" />
|
||||
</Compiler>
|
||||
<Unit filename=".gitignore" />
|
||||
<Unit filename="main.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Extensions />
|
||||
</Project>
|
||||
</CodeBlocks_project_file>
|
@ -0,0 +1,48 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
double A, C, p;
|
||||
|
||||
printf("Enter the initial cost of the product: ");
|
||||
scanf(" %lf", &A);
|
||||
|
||||
printf("Enter the desired cost of the product: ");
|
||||
scanf(" %lf", &C);
|
||||
|
||||
while(A <= C)
|
||||
{
|
||||
|
||||
printf("The initial cost is already lower or equal to the desired one. \nEnter the desired one again: ");
|
||||
scanf(" %lf", &C);
|
||||
}
|
||||
|
||||
printf("Enter the percentage reduction in the cost of the product for the year: ");
|
||||
scanf(" %lf", &p);
|
||||
|
||||
//printf("A = %lf \nC = %lf \np = %lf \n", A,C,p);
|
||||
|
||||
for(int i = 1; i <= 10; i++)
|
||||
{
|
||||
A *= (1 - (p / i) / 100);
|
||||
printf("A = %lf\n", A);
|
||||
|
||||
if(A < C)
|
||||
{
|
||||
printf("The cost of the product dropped below the desired cost after %d years\n", i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(A > C)
|
||||
{
|
||||
printf("The cost of the product did not fall below the desired cost\n");
|
||||
}
|
||||
|
||||
|
||||
printf("Press any key to exit...\n");
|
||||
getchar();
|
||||
getchar();
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
/obj
|
||||
/bin
|
||||
/Project2.depend
|
||||
/Project2.layout
|
@ -0,0 +1,55 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
int main() {
|
||||
float A, B;
|
||||
int n;
|
||||
|
||||
// Input values A and B
|
||||
printf("Enter value A: ");
|
||||
scanf("%f", &A);
|
||||
printf("Enter value B: ");
|
||||
scanf("%f", &B);
|
||||
|
||||
// Input size of vector X
|
||||
printf("Enter size of vector X: ");
|
||||
scanf("%d", &n);
|
||||
|
||||
// Create vector X
|
||||
float* X = (float*)malloc(n * sizeof(float));
|
||||
if (X == NULL) {
|
||||
printf("Memory allocation error.\n");
|
||||
return 1; // Exit the program with an error
|
||||
}
|
||||
|
||||
// Input elements of vector X
|
||||
for (int i = 0; i < n; i++) {
|
||||
printf("Enter element X[%d]: ", i);
|
||||
scanf("%f", &X[i]);
|
||||
}
|
||||
|
||||
// Initialize sum and counter
|
||||
float total_sum = 0;
|
||||
int count = 0;
|
||||
|
||||
// Iterate over elements of vector X and check condition
|
||||
for (int i = 0; i < n; i++) {
|
||||
if (fabs(X[i] - A) < B) { // Check condition
|
||||
total_sum += X[i]; // Sum the suitable element
|
||||
count++; // Increase the counter
|
||||
}
|
||||
}
|
||||
|
||||
// Output results
|
||||
printf("Sum: %.2f\n", total_sum);
|
||||
printf("Count of elements: %d\n", count);
|
||||
|
||||
// Free allocated memory
|
||||
free(X);
|
||||
|
||||
printf("Press any key to exit...\n");
|
||||
getchar(); // To consume the newline character left by previous input
|
||||
getchar(); // Wait for user input
|
||||
return 0; // Exit the program
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
/bin
|
||||
/obj
|
||||
/Project3.depend
|
||||
/Project3.layout
|
@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||
<CodeBlocks_project_file>
|
||||
<FileVersion major="1" minor="6" />
|
||||
<Project>
|
||||
<Option title="Project3" />
|
||||
<Option pch_mode="2" />
|
||||
<Option compiler="gcc" />
|
||||
<Build>
|
||||
<Target title="Debug">
|
||||
<Option output="bin/Debug/Project3" prefix_auto="1" extension_auto="1" />
|
||||
<Option object_output="obj/Debug/" />
|
||||
<Option type="1" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-g" />
|
||||
</Compiler>
|
||||
</Target>
|
||||
<Target title="Release">
|
||||
<Option output="bin/Release/Project3" prefix_auto="1" extension_auto="1" />
|
||||
<Option object_output="obj/Release/" />
|
||||
<Option type="1" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-O2" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
</Linker>
|
||||
</Target>
|
||||
</Build>
|
||||
<Compiler>
|
||||
<Add option="-Wall" />
|
||||
</Compiler>
|
||||
<Unit filename=".gitignore" />
|
||||
<Unit filename="main.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Extensions>
|
||||
<lib_finder disable_auto="1" />
|
||||
</Extensions>
|
||||
</Project>
|
||||
</CodeBlocks_project_file>
|
@ -0,0 +1,59 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#define MAX_ROWS 100
|
||||
#define MAX_COLS 100
|
||||
|
||||
int main() {
|
||||
int n, m;
|
||||
int A[MAX_ROWS][MAX_COLS];
|
||||
|
||||
// Input matrix dimensions
|
||||
printf("Enter the number of rows (n): ");
|
||||
scanf("%d", &n);
|
||||
printf("Enter the number of columns (m): ");
|
||||
scanf("%d", &m);
|
||||
|
||||
// Input matrix elements
|
||||
printf("Enter the elements of matrix A (%d x %d):\n", n, m);
|
||||
for (int i = 0; i < n; i++) {
|
||||
for (int j = 0; j < m; j++) {
|
||||
scanf("%d", &A[i][j]);
|
||||
}
|
||||
}
|
||||
|
||||
// Replace zero elements
|
||||
for (int j = 0; j < m; j++) {
|
||||
int firstNonZero = -1;
|
||||
|
||||
// Find the first non-zero element in the column
|
||||
for (int i = 0; i < n; i++) {
|
||||
if (A[i][j] != 0) {
|
||||
firstNonZero = A[i][j];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Replace zero elements with the found first non-zero value
|
||||
if (firstNonZero != -1) { // If a non-zero element was found
|
||||
for (int i = 0; i < n; i++) {
|
||||
if (A[i][j] == 0) {
|
||||
A[i][j] = firstNonZero;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Output modified matrix
|
||||
printf("Modified matrix A:\n");
|
||||
for (int i = 0; i < n; i++) {
|
||||
for (int j = 0; j < m; j++) {
|
||||
printf("%d ", A[i][j]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
printf("Press any key to exit...\n");
|
||||
getchar();
|
||||
getchar();
|
||||
return 0;
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
// you may type whatever you want
|
||||
int main()
|
||||
{
|
||||
cout << "Enter A and B: " << endl;
|
||||
double a, b;
|
||||
cin >> a >> b;
|
||||
cout << "A + B = " << a + b << '\n'
|
||||
<< "A - B = " << a - b << '\n'
|
||||
<< "A * B = " << a * b << '\n'
|
||||
<< "A / B = " << a / b << '\n';
|
||||
|
||||
if (a > b || a == b)
|
||||
{
|
||||
cout << "Maximum: " << a << '\n';
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << "Maximum: " << b << endl;
|
||||
}
|
||||
|
||||
if (a < b || a == b)
|
||||
{
|
||||
cout << "Minimum: " << a << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << "Minimum: " << b << endl;
|
||||
}
|
||||
|
||||
std::cout << "Press 'Enter' for exit...";
|
||||
std::cin.ignore(); // èãíîðèðóåì ñèìâîë íîâîé ñòðîêè èç ïðåäûäóùåãî ââîäà
|
||||
std::cin.get();
|
||||
return 0;
|
||||
}
|
Загрузка…
Ссылка в новой задаче