This commit is contained in:
Peter Sabol 2022-03-18 15:37:22 +01:00
parent 5f89a7763e
commit 1904ba3ae3
3 changed files with 26 additions and 34 deletions

1
du3/Makefile Normal file
View File

@ -0,0 +1 @@
gcc -std=c11 -lm program.c -o program

Binary file not shown.

View File

@ -1,41 +1,19 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#define LINE_SIZE 100
//#include<conio.h> //#include<conio.h>
/*int main() /*void main() {
{
float a[100],sum=0,x;
int n,i;
printf("\nEnter the value of X :: ");
scanf("%f",&x);
// printf("\nEnter degree of the polynomial X :: ");
//scanf("%d",&n);
printf("\nEnter coefficient's of the polynomial X :: \n");
for(i=n;i>=0;i--)
{
printf("\nEnter Coefficient of [ X^%d ] :: ",i);
scanf("%f",&a[i]);
}
for(i=n;i>0;i--)
{
sum=(sum+a[i])*x;
}
sum=sum+a[0];
printf("\nValue of the polynomial is = [ %f ]\n",sum);
return 0;
}
*/
void main() {
int degree,x; int degree,x;
int coeff[10], i; int coeff[10], i;
int sum = 0; int sum = 0;
// Getting the value of the variable
printf("\nEnter the value of x: ");
scanf("%d",&x);
// Getting the degreee of the polynomial // Getting the degreee of the polynomial
printf("\nEnter the degree of the polynomial: "); printf("\nEnter the degree of the polynomial: ");
scanf("%d",&degree); scanf("%d",&degree);
@ -46,10 +24,6 @@ void main() {
scanf("%d",&coeff[i]); scanf("%d",&coeff[i]);
} }
// Getting the value of the variable
printf("\nEnter the value of x: ");
scanf("%d",&x);
// Applying Horner's rule // Applying Horner's rule
sum = coeff[degree]; sum = coeff[degree];
for(i=degree-1; i>=0; i--) { for(i=degree-1; i>=0; i--) {
@ -59,3 +33,20 @@ void main() {
// Printing result // Printing result
printf("\nResult: %d",sum); printf("\nResult: %d",sum);
} }
*/
int main(){
int pole[LINE_SIZE];
int n=0;
char*vstup;
char riadok[LINE_SIZE];
do {
vstup=fgets(riadok,LINE_SIZE,stdin);
n++;
}while(*vstup!='\n');
//printf("%s",*vstup);
for(int i=0;n>i;i++){
printf("%s",vstup);
}
}