- •Int main()
- •Int main()
- •Int main()
- •Int main()
- •Int main()
- •Максимальная сумма элементов из нескольких массивов(функция с переменным числом параметров)
- •Int main()
- •Замена абсолютно любых слов местами (просто в программе цифорки нужные поменять) Где цифры жирные там менять по ситуации
- •Int main()
- •Int main()
- •Int main()
- •Int main()
- •Int main()
- •Int main()
- •Int main()
- •Int main()
- •Int main()
- •Int main()
- •Int main()
- •Строка в числа(в комментах код для подсчёта количества слов или чисел в строке рекурсией, это тоже где-то надо, вроде бы)
- •Int main()
- •Int main()
- •Int main()
Int main()
{
int t,i,num1,k1=10,k2=11;
double num;
printf("Enter number: ");
scanf("%lf",&num);
printf("Enter accarsity: ");
scanf("%d",&t);
printf("Enter cc: ");
scanf("%d",&ss);
num<0?znak='-',num*=-1:num;
num1=num;
num-=num1;
while(num1>=ss)
{
i=num1%ss;
num1/=ss;
ms[k1--]=i>9?i-10+'A':i+'0';
}
ms[k1--]=num1>9?num1-10+'A':num1+'0';
ms[k1]=znak;
ms[k2++]='.';
while(num!=0&&k2-11<=t)
{
num*=ss;
i=num*ss;
num-=i;
ms[k2++]=i>9?i-10+'A':i+'0';
}
for(i=k1;i<k2;i++)
printf("%c",ms[i]);
getch();
return 0;
}
Минимальное в массиве строк
#include<stdio.h>
#include<conio.h>
#include<malloc.h>
#include<windows.h>
void GetStr(char*str,int size)
{
int i;
char c;
for(i=0;size>0&&(c=getche())!=13;size--,i++)
{
str[i]=c;
}
str[i]='\0';
}
int GetWord(char*str,int *i)
{
int len=0;
while(str[*i]==32)
(*i)++;
if(str[*i]=='\0')
return 0;
while(str[*i]!=32 && str[*i]!='\0')
{
len++;
(*i)++;
}
return len;
}
Int main()
{
char** arr;
int number, size,i,lenght=0,location=0,minlenght,l_minword,index;
printf("Enter,how many strings do you want: ");
scanf("%d",&number);
arr=(char**)malloc(number*sizeof(char*));
printf("Enter,how many symbols in strings do you want: ");
scanf("%d",&size);
for(i=0;i<number;i++)
arr[i]=(char*)malloc(size+1*sizeof(char));
system("cls");
for(i=0;i<number;i++)
{
printf("Enter string number %d: ",(i+1));
GetStr(arr[i],size);
system("cls");
}
lenght=GetWord(arr[0],&location);
minlenght=lenght;
l_minword=location;
for(i=0,index=0;i<number;i++)
{
while(arr[i][location]!='\0')
{
lenght=GetWord(arr[i],&location);
if(lenght<minlenght)
{
minlenght=lenght;
l_minword=location;
index=i;
}
}
location=0;
}
for(i=l_minword-minlenght;i<=l_minword;i++)
printf("%c",arr[index][i]);
for(i=0;i<number;i++)
free(arr[i]);
free(arr);
getch();
return 0;
}
НОД рекурсией
#include<stdio.h>
#include<conio.h>
int Nod(int n,int m)
{
if(n<m)
{
int temp=n;
n=m;
m=temp;
}
if(n%m==0)
return m;
else
return Nod(n%m,m);
}
Int main()
{
int number1, number2;
int nod;
scanf("%d%d",&number1,&number2);
nod=Nod(number1,number2);
printf("\n%d",nod);
getch();
return 0;
}
Реверс каждого слова в строке
#include<stdio.h>
#include<conio.h>
#include<malloc.h>
void GetStr(char*str,int size)
{
int i;
char c;
for(i=0;size>0&&(c=getche())!=13;size--,i++)
{
str[i]=c;
}
str[i]='\0';
}
int GetWord(char*str,int *i)
{
int len=0;
while(str[*i]==32)
(*i)++;
if(str[*i]=='\0')
return 0;
while(str[*i]!=32 && str[*i]!='\0')
{
len++;
(*i)++;
}
return len;
}
void Revers(char *str,int l, int r)
{
r--;
while(l<r)
{
int temp=str[l];
str[l]=str[r];
str[r]=temp;
l++;
r--;
}
}
Int main()
{
char *string;
int size,location=0,left,lenght;
printf("Enter how many symbols do you want: ");
scanf("%d",&size);
string=(char*)malloc(size*sizeof(char));
printf("Enter string: ");
GetStr(string,size);
while(string[location]!='\0')
{
lenght=GetWord(string,&location);
left=location-lenght;
Revers(string,left,location);
}
printf("\n%s",string);
free(string);
getch();
return 0;
}
Реверс строки
#include<stdio.h>
#include<conio.h>
#include<malloc.h>
void GetStr(char*str,int size)
{
int i;
char c;
for(i=0;i<size&&(c=getche())!=13;i++)
{
str[i]=c;
}
str[i]='\0';
}
void Revers(char *str)
{
int i=0, j;
for(j=0;str[j+1]!='\0';j++);
while(i<j)
{
int temp=str[i];
str[i]=str[j];
str[j]=temp;
i++;
j--;
}
}
