Anonymous
Francisco
Just the necessary headers, not the whole STL
Anonymous
Francisco
Francisco
Anonymous
Just post what you've done so far, I'm not going to do it for you
#include<bits/stdc++.h>
using namespace std;
void missing_char(string str)
{
string new_str="";
int i;
int x=str.length();
for(i=0;i<x;i++)
{
// if(i==x-1)
// break;
if(str[i]!=str[x-1-i])
{
new_str+=str[x-1-i];
}
}
string temp=new_str+str;
cout<<"Insert "<<new_str<<" at the beginning to make it "<<temp;
}
int main()
{
string str;
cout<<"Enter the string : ";
cin>>str;
int x=str.length();
cout<<"\n"<<x<<endl;
cout<<str[x-1]<<"\n";
// int y=missing_char(str);
// cout<<"\nThe missing character is "<<str[y]<<" at position "<<x-y+1<< " to make "<<str<<" pallindrome.";
missing_char(str);
return 0;
}
Anonymous
Ребят, привет
Dima
Anonymous
Ok
Anonymous
Soryy
Anonymous
@fgallego96 here's the code without mess... The previous was mess
#include<bits/stdc++.h>
using namespace std;
void missing_char(string str)
{
string new_str="";
int i;
int x=str.length();
for(i=0;i<x;i++)
{
if(str[i]!=str[x-1-i])
{
new_str+=str[x-1-i];
}
}
string temp=new_str+str;
cout<<"Insert "<<new_str<<" at the beginning to make it "<<temp;
}
int main()
{
string str;
cout<<"Enter the string : ";
cin>>str;
int x=str.length();
cout<<"\n"<<x<<endl;
cout<<str[x-1]<<"\n";
missing_char(str);
return 0;
}
Anonymous
Guys, hello. Please help with my code
Anonymous
Anonymous
#include <stdio.h>
//Compiler version gcc 6.3.0
int main()
{
int i, sum=0;
printf("Numbers between A and B, divisible by 3 : \n");
printf ("input A");
scanf "A";
printf ("input B");
scanf "B";
{
if(i%3==0)
{
printf("% 5d",i);
}
}
printf("%d \n");
}
Anonymous
Anonymous
Anonymous
Anonymous
Guys help plz
MengShu
I will practice it from now onwards
https://stackoverflow.com/questions/1452721/why-is-using-namespace-std-considered-bad-practice
You can refer to this for the topic.
Vitaliy ◀️TriΔng3l▶️
MengShu
Anonymous
Anonymous
#include <stdio.h>
//Compiler version gcc 6.3.0
int main()
{
int i, sum=0;
printf("Numbers between A and B, divisible by 3 : \n");
printf ("input A");
scanf "A";
printf ("input B");
scanf "B";
{
if(i%3==0)
{
printf("% 5d",i);
}
}
printf("%d \n");
}
#include <stdio.h>
//Compiler version gcc 6.3.0
int main()
{
int i, sum=0,A,B;
printf ("input A : ");
scanf ("%d",&A);
printf ("input B : ");
scanf ("%d",&B);
printf("Numbers between A and B, divisible by 3 : \n");
for(i=A;i<B;i++)
{
if(i%3==0)
{
printf("%d",i);
printf(" ");
}
}
}
Anonymous
@WanzOr Have a look at this and try understanding it
Anonymous
Anonymous
Very much
Anonymous
One modification—-> for(i=A;i<=B;i++)
Not i<B
Anonymous
OMG
Dima
Anonymous
😊
yoav
char firstCapitalChar(char* str, int length, char putHereA){
if(str[length] == putHereA)return(str[length]);
else if(length == 0)return (char)0;
else if(putHereA == 'Z')return firstCapitalChar(str, length - 1, 'A');
else{
return firstCapitalChar(str, length, putHereA+1);
}
} this recursive function need to return me the first capital letter but it returning the last capital letter why?
Anonymous
char firstCapitalChar(char* str, int length, char putHereA){
if(str[length] == putHereA)return(str[length]);
else if(length == 0)return (char)0;
else if(putHereA == 'Z')return firstCapitalChar(str, length - 1, 'A');
else{
return firstCapitalChar(str, length, putHereA+1);
}
} this recursive function need to return me the first capital letter but it returning the last capital letter why?
Maybe you need to pass the starting index and the last index of the string into your recursive function.... I made one and its working fine... Have a look
#include<bits/stdc++.h>
using namespace std;
char first_capital(string str,int start,int len)
{
if(start==len)
return str[len];
else if(str[start]>='A'&&str[start]<='Z')
return str[start];
else
return first_capital(str,start+1,len);
}
int main()
{
string str;
cin>>str;
cout<<"The first capital letter in the string is : "<<first_capital(str,0,str.length());
return 0;
}
Anonymous
As you need to get the first capital letter, so we need to check the character from the starting index, if found then return it, else increment the starting index... And the base condition would be that if the starting index becomes equal to the length of the string, then it will exit.
Anonymous
And we have assumed that there is a capital letter in the string that we pass
gallo
Hi,I'm working on an exercise for the Classes, I created the class Matrix3D and I created the methods getdim and print.
Mar!o
And?
gallo
Now I want to create a method sum, to sum 2 Matrixes(with the same dimensions) , the method must to do with pointers and must return a pointer, Matrix3D* sum(Matrix3D* m1, Matrix3D* m2) , but how can I select every element of m1 and m2 and put the sum in mat_sum?
gallo
https://pastebin.com/A6w8fJUY this is the code that I wrote but I don't know what I should put in the FOR to select the elements,to sum and to put in mat_sum
Mar!o
Why are you using dynamic allocation for the sum
gallo
gallo
Matrix3D* mat_sum
Mar!o
Can I see the header file pls
gallo
Mar!o
Ty
gallo
Ty
https://pastebin.com/z8hbe1Ri
Mar!o
Matrice3D Matrice3D::sum(const Matrice3D& m1, const Matrice3D& m2) {
Matrice3D mat_sum{};
for(int i=0;i<a;i++)
for(int j=0;j<b;j++)
for(int h=0;h<c;h++){
//Add
}
return mat_sum;
}
Mar!o
Without extra dynamic allocation
gallo
Panther 🔱
Hi this is pavan
I want to start c from basics.
Mar!o
Panther 🔱
Can any one suggest good website or videos
Panther 🔱
To become perfect in ccoding
Panther 🔱
Hi mario plz suggest
gallo
Dima
Mar!o
gallo
?
I must do with pointers!!! This is the exercise
Mar!o
gallo
I know 😁
I think you can't get my question
gallo
gallo
gallo
Maksim
hello, i'm newbee, who can help me? I try to use "scanf" function, but i get "missed returned value". (Visual Studio)
scanf("%d", &symbol);
I_Interface
I_Interface
I_Interface
Then code it.
I_Interface
Maksim
#include <stdio.h>
#include <locale.h>
int main(void)
{
setlocale(LC_ALL, "");
int symbol;
printf("Введите значение символа в коде UTF8: \n");
scanf("%d", &symbol);
printf("Код %d соответствует символу: %c \n", symbol, symbol);
return 0;
}
Pankaj
Anybody knows how to update text value in qml using c++ signal in, Qt
I_Interface
gallo
m1 is a object Matrix that contains a matrix3D
Maksim
Mar!o
The theory is the same if they are pointery, blobs, objects
gallo
But I don't know how to select the elements of the matrix contained in the objects