Anonymous
First step we multiple 21-19-17-71-76-73-153-164-157 with matris2
Anonymous
I check first step. This is my code. int main() { int matris1[5][5] = {{21, 19, 17, 25, 28}, {71, 76, 73, 88, 59}, {153, 164, 164, 157, 155}, {200, 201, 190, 185, 180}, {205, 210, 215, 230, 232}}; int matris2[3][3] = {{-1, -1, -1}, {-1, 8, -1}, {-1, -1, -1}}; int i, j, sum, arr2Size = 3, arr1Size = 5, d = 0, k = 0, m = 0, s; int out = (arr1Size - arr2Size + (2 * d)) / 1 + 1; printf("%d", out); int temp[out][out]; for (i = 0; i < arr2Size; i++) { for (j = 0; j < arr2Size; j++) { sum += matris1[i][j] * matris2[i][j]; } temp[k][m] = sum; } printf("%d ", sum); printf("%d ", temp[0][0]); return 0; }
Anonymous
But i cant find how i swipe one column right
Anonymous
I collect them in temp matris
Rio
Hello
Naweethmnm
Hello
olli
Hi everyone. I have a problem. I can find -74 but i dont know how to swipe big matris to right. Can you help me please. I cant send pic. Lets think matris1 is 21 19 17 25 28 71 76 73 68 59 153 164 157 155 200 201 190 185 180 205 210 215 230 232 Matris 2 -1 -1 -1 -1 8 -1 -1 -1 -1 First we multiple matris1 * matris2 but size is matris2size then we have to do swipe right. Like we multiple 19*-1 +17*-1+ 25 *-1 + 76*-1+73*8+ 68*-1+ 164*-1+164*-1+157*-1 I hope you guys understand. I cant share pic. So sorry.
not sure the explanation is entirely clear. Given the two matrices 21 19 17 25 28 71 76 73 68 59 153 164 164 157 155 200 201 190 185 180 205 210 215 230 232 and -1 -1 -1 -1 8 -1 -1 -1 -1 In the first step we should multiple these two, right? 21 19 17 -1 -1 -1 71 76 73 x -1 8 -1 153 164 164 -1 -1 -1 Which result do you expect? Is it a single number or is it an actual matrix multiplication? And which multiplication do you perform next? This one? 19 17 25 1 -1 -1 76 73 68 x -1 8 -1 164 164 157 -1 -1 -1
Anonymous
Yes
Anonymous
And then we swipe one row down like that
Anonymous
We collect results in temp array that i write and this array elements after all things is -74 -96 -114 184 258 182 107 -6 -43
Anonymous
Can i send pic of this in privately
olli
gotcha, I think it's clear enough now. In your code you don't change k or m. So you probably need to more for loops to iterate over your temp matrix, e.g. for (int k = 0; k < ResultDimension; ++k) { for (int m = 0; m < ResultDimension; ++m) { /* In here compute the "multiplication" for every i and j in range Sum += matris1[i + k][j + m] * matris2[i][j]; */ Result[k][m] = Sum; } }
Satyajit
How to start learning C
Satyajit
Please name few good and reliable resources.
olli
Please name few good and reliable resources.
https://iso-9899.info/n1570.html https://en.cppreference.com/w/c http://cslibrary.stanford.edu/101/EssentialC.pdf
Satyajit
Thank you so much
Prince Fine
hey Guys can i get some help pls i have managed to take input(complex no )
Prince Fine
struct complex { float real; float imaginary; }
Prince Fine
then i took the input separately but what if the user enter this 4 types how can i validate them 3 + 2i , 2i + 3 , 3 ,2i
klimi
1. take the whole line 2. split by , 3. validate each number
Prince Fine
Complex getComplex(){ Complex c; char ch; bool error; do{ error=false; c.real=c.imag=0; cout<<"Enter complex number(a + bi): "; cin>>c.real; if(!cin){ cin.clear(); if(cin.peek()=='i'){ //if i or i + 4 and any error situation cin.get(); removeWhite(); ch=cin.peek(); if(ch=='+'){ cin.get(); removeWhite(); if(isdigit(cin.peek())){ c.imag=1; cin>>c.real; removeWhite(); if(cin.peek() != '\n'){ error=true; } }else{ error=true; } }else if(ch=='\n'){ c.imag=1; }else{ error=true; } }else error=true; }else{ //case 4, 4i, 4i + 3 considering also all error situation removeWhite(); ch=cin.peek(); switch(ch){ case '\n': break; case 'i': cin.get(); removeWhite(); ch=cin.peek(); if(ch=='+' || ch=='\n'){ c.imag=c.real; c.real=0; if(ch=='+'){ cin.get(); removeWhite(); if(isdigit(cin.peek())){ cin >> c.real; removeWhite(); if(cin.peek()!='\n'){ error=true; } } } }else{ error=true; } break; case '+': cin.get(); //remove the + sign removeWhite(); ch=cin.peek(); if(isdigit(ch)){ cin>>c.imag; removeWhite(); ch=cin.peek(); if(ch=='i'){ cin.get(); //remove i removeWhite(); if(cin.peek()!='\n'){ error=true; } }else{ error=true; } }else if(ch=='i'){ cin.get(); //remove i removeWhite(); if(cin.peek()!='\n'){ error=true; }else{ c.imag=1; } }else{ error=true; } break; default: error=true; } } cin.ignore(INT_MAX,'\n'); //empty buffer if(error){ cout << "Invalid complex number. Please reenter!!!"<<endl; } }while(error); return c; }
Prince Fine
Complex getComplex(){ Complex c; char ch; bool error; do{ error=false; c.real=c.imag=0; cout<<"Enter complex number(a + bi): "; cin>>c.real; if(!cin){ cin.clear(); if(cin.peek()=='i'){ //if i or i + 4 and any error situation cin.get(); removeWhite(); ch=cin.peek(); if(ch=='+'){ cin.get(); removeWhite(); if(isdigit(cin.peek())){ c.imag=1; cin>>c.real; removeWhite(); if(cin.peek() != '\n'){ error=true; } }else{ error=true; } }else if(ch=='\n'){ c.imag=1; }else{ error=true; } }else error=true; }else{ //case 4, 4i, 4i + 3 considering also all error situation removeWhite(); ch=cin.peek(); switch(ch){ case '\n': break; case 'i': cin.get(); removeWhite(); ch=cin.peek(); if(ch=='+' || ch=='\n'){ c.imag=c.real; c.real=0; if(ch=='+'){ cin.get(); removeWhite(); if(isdigit(cin.peek())){ cin >> c.real; removeWhite(); if(cin.peek()!='\n'){ error=true; } } } }else{ error=true; } break; case '+': cin.get(); //remove the + sign removeWhite(); ch=cin.peek(); if(isdigit(ch)){ cin>>c.imag; removeWhite(); ch=cin.peek(); if(ch=='i'){ cin.get(); //remove i removeWhite(); if(cin.peek()!='\n'){ error=true; } }else{ error=true; } }else if(ch=='i'){ cin.get(); //remove i removeWhite(); if(cin.peek()!='\n'){ error=true; }else{ c.imag=1; } }else{ error=true; } break; default: error=true; } } cin.ignore(INT_MAX,'\n'); //empty buffer if(error){ cout << "Invalid complex number. Please reenter!!!"<<endl; } }while(error); return c; }
@K11M1 what else should i do or is there any shortcut to validate?
Rio
Who Can help me in one task please
Rio
I need help
klimi
I need help
with the details you have provided, i don't think anyone can
Anonymous
Complex getComplex(){ Complex c; char ch; bool error; do{ error=false; c.real=c.imag=0; cout<<"Enter complex number(a + bi): "; cin>>c.real; if(!cin){ cin.clear(); if(cin.peek()=='i'){ //if i or i + 4 and any error situation cin.get(); removeWhite(); ch=cin.peek(); if(ch=='+'){ cin.get(); removeWhite(); if(isdigit(cin.peek())){ c.imag=1; cin>>c.real; removeWhite(); if(cin.peek() != '\n'){ error=true; } }else{ error=true; } }else if(ch=='\n'){ c.imag=1; }else{ error=true; } }else error=true; }else{ //case 4, 4i, 4i + 3 considering also all error situation removeWhite(); ch=cin.peek(); switch(ch){ case '\n': break; case 'i': cin.get(); removeWhite(); ch=cin.peek(); if(ch=='+' || ch=='\n'){ c.imag=c.real; c.real=0; if(ch=='+'){ cin.get(); removeWhite(); if(isdigit(cin.peek())){ cin >> c.real; removeWhite(); if(cin.peek()!='\n'){ error=true; } } } }else{ error=true; } break; case '+': cin.get(); //remove the + sign removeWhite(); ch=cin.peek(); if(isdigit(ch)){ cin>>c.imag; removeWhite(); ch=cin.peek(); if(ch=='i'){ cin.get(); //remove i removeWhite(); if(cin.peek()!='\n'){ error=true; } }else{ error=true; } }else if(ch=='i'){ cin.get(); //remove i removeWhite(); if(cin.peek()!='\n'){ error=true; }else{ c.imag=1; } }else{ error=true; } break; default: error=true; } } cin.ignore(INT_MAX,'\n'); //empty buffer if(error){ cout << "Invalid complex number. Please reenter!!!"<<endl; } }while(error); return c; }
This is too complicated. What you want to do instead is to define a user defined literal. This code accepts literals in all the formats you described: https://pastebin.com/6hU3wNU3 It is just meant to show you how to do it. Think carefully about the operator overloads. Also I made all the data members public (which you normally do in such classes). Moreover there is a class called complex in the standard library already.
Prince Fine
then i took the input separately but what if the user enter this 4 types how can i validate them 3 + 2i , 2i + 3 , 3 ,2i
this were just an examples that the user might enter the no.s i want the user to enter
Anonymous
this were just an examples that the user might enter the no.s i want the user to enter
Look at the code link I sent above. It already accepts literals in all the formats
Prince Fine
first user will enter the no in this 4 formats a , bi , a+bi , bi + a and then i want the code to accept and validate it so that complex c (c.real will find the real no even if the user enter the imaginary first)
Prince Fine
Look at the code link I sent above. It already accepts literals in all the formats
i run it but since there's no cin the code cant accept any value from the user
Anonymous
i run it but since there's no cin the code cant accept any value from the user
Ok. The code I gave is for literal values. If you want to accept user input in a+bi form, then this is not the solution. To be able to accept user inputs of a specific form, you must overload operator >> for your class and then parse it yourself. I misunderstood what you wanted.
Anonymous
it only displays 6 and 8
Yes it displays the real and imaginary part of 'c' which happen to be 6 and 8 respectively because of the operations above it
Prince Fine
Complex getComplex(){ Complex c; char ch; bool error; do{ error=false; c.real=c.imag=0; cout<<"Enter complex number(a + bi): "; cin>>c.real; if(!cin){ cin.clear(); if(cin.peek()=='i'){ //if i or i + 4 and any error situation cin.get(); removeWhite(); ch=cin.peek(); if(ch=='+'){ cin.get(); removeWhite(); if(isdigit(cin.peek())){ c.imag=1; cin>>c.real; removeWhite(); if(cin.peek() != '\n'){ error=true; } }else{ error=true; } }else if(ch=='\n'){ c.imag=1; }else{ error=true; } }else error=true; }else{ //case 4, 4i, 4i + 3 considering also all error situation removeWhite(); ch=cin.peek(); switch(ch){ case '\n': break; case 'i': cin.get(); removeWhite(); ch=cin.peek(); if(ch=='+' || ch=='\n'){ c.imag=c.real; c.real=0; if(ch=='+'){ cin.get(); removeWhite(); if(isdigit(cin.peek())){ cin >> c.real; removeWhite(); if(cin.peek()!='\n'){ error=true; } } } }else{ error=true; } break; case '+': cin.get(); //remove the + sign removeWhite(); ch=cin.peek(); if(isdigit(ch)){ cin>>c.imag; removeWhite(); ch=cin.peek(); if(ch=='i'){ cin.get(); //remove i removeWhite(); if(cin.peek()!='\n'){ error=true; } }else{ error=true; } }else if(ch=='i'){ cin.get(); //remove i removeWhite(); if(cin.peek()!='\n'){ error=true; }else{ c.imag=1; } }else{ error=true; } break; default: error=true; } } cin.ignore(INT_MAX,'\n'); //empty buffer if(error){ cout << "Invalid complex number. Please reenter!!!"<<endl; } }while(error); return c; }
here
Anonymous
have you seen the first one 👀
Yes. Now I understood what you wanted clearly. You should post huge chunks of code using sites like pastebin ratherthan pasting it here. Makes it easier for people to understand your code then.
Anonymous
Does anyone knows divide and conquer method nicely?
mito
Does anyone knows divide and conquer method nicely?
look through the algorithm of merge sort.
Nana
Does anyone knows divide and conquer method nicely?
divide and conquer means dividing a problem into small or subproblems, solve the subproblems and finally combines the solutions to the subproblems to solve the overall problem
Anonymous
I will be needing some help in it
Nana
Okay
Prince Fine
I will be needing some help in it
well if you need a power point document about it i can share you
Prince Fine
from my school
Anonymous
Anyone here is quite pro in competitive programming?
klimi
Anyone here is quite pro in competitive programming?
Just ask your question, dont as meta questions
Anonymous
Anonymous
Does anyone of you know a YouTube channel or a website that teaches iteration in C? Thank youu
klimi
iteration as in development process or loops?
Anonymous
Does anyone of you know a YouTube channel or a website that teaches iteration in C? Thank youu
Search for pointer and arrays tutorials. In C, iteration is achieved using pointers and if you are comfortable iterating using them on an array, you can do so on any datastructure that you create.
Anonymous
Actually my professor introduced us to iteration first before arrays that's why I'm having trouble coding an iterative program for padovan sequence
Anonymous
Actually my professor introduced us to iteration first before arrays that's why I'm having trouble coding an iterative program for padovan sequence
Well then you can learn about arrays online. There are a lot of sources available online and in YouTube. Stay away from Indian instructors as far as possible.
Prince Fine
Anonymous
bucky he is kinda good
Is he in YouTube?
Prince Fine
Anonymous
yea
Thank you. I'll try watching his tutorials😊
Prince Fine
it's channel name is thenewboston
Prince Fine
https://youtu.be/1kLw8kZuccQ
ɛ n h ᴀ n c ɛ ґ 🧟‍♂️
Prince Fine
btw guys can you make a telegram bot using C++?
Anonymous
btw guys can you make a telegram bot using C++?
Telegram Bot API is a HTTP based API. You can use any language through which you can make a web request and receive a response and process it. There are tonnes of open source libraries for C++ that can be used for this purpose.
Anonymous
btw guys can you make a telegram bot using C++?
You can do anything in C/++. Sometimes it just takes more time if there is less support for the particular thing. But as people said above me, it's http based, so you just need a http client library and you are good to go.
Prince Of Persia
btw guys can you make a telegram bot using C++?
Yes There are some libraries that make it easy for you
4hk
Oh sry, https://pastebin.com/X4a8aYTN. how can I create a .txt with the data that was entered in "getDatos()", I am using <fstream> but there is an error that I don't understand
coal
also i figured that "abrirFile" is not defined anywhere in your code