World Stream
But cwithme id a chainal not a group
World Stream
Is*
Anonymous
Need a personal instructor to help with college first semester coding . Preferably indian . Dm me if anyone wants to help . Thank you .
Xudoyberdi
Anonymous
MRT
/warn no
MRT
:D
Akansha
Program to overload ++ operator to increment date
Programmer
priya
The program is to print till the first non alphabet character
My code is:
priya
#include<stdio.h>
#include <stdlib.h>
int main()
{
char a[1001];
scanf("%[A-Za-z0-9]s",a);
printf("%s",a);
}
but only 4/11 test case passed
I know that I can use isaplha but I just wanna know why my code didn't work
could anyone help me out
Avique
Sometimes a teacher is needed
in theory, i know c++ well, but i had not used it directly since many years ago, and now i have a bit of dyslexia, which helped me (i guess) not seeing the silly mistake for a few days, and concluded it was another kind of problem - which is fairly common to me.
Programmer
Bojan_Krdemn
https://pastebin.com/YFrgCzyN
Hi! Can you criticize (evaluate) the algorithm here? Seems to work, but if anything
Bojan_Krdemn
long have i suffered to make it work , but finally it works though something distubs me
Apk
What do they consider in alphanumeric characters? Because some characters like & and @ are also considered alphanumeric
priya
Apk
Anonymous
I don't actually know C++ and couldn't say if this has memory leaks or other badness.
https://nekobin.com/tebukihota
Anonymous
Apk
World Stream
/warn no
Why are you warn me, this is not a snapping word
Simone
Guys Hi, I have a problem with C
Simone
coordinate * percorso(taxi *ts,coordinate arrivo, matrix *mat, int index){
int arrivato = 0;
coordinate result[SO_HEIGHT*SO_WIDTHS];
result[0].x = -1;
result[0].y = -1;
int i = 0;
while (!arrivato){
if(mat->mat[ts[index].init2.x+1][ts[index].init2.y].type != 'X' && ts[index].init2.x > 0 && ts[index].init2.x < arrivo.x){
result[i].x = ts[index].init2.x +1;
result[i].y = ts[index].init2.y;
i++;
}else if(mat->mat[ts[index].init2.x][ts[index].init2.y+1].type != 'X' && ts[index].init2.y > 0 && ts[index].init2.y < arrivo.y){
result[i].x = ts[index].init2.x;
result[i].y = ts[index].init2.y+1;
i++;
}else if(mat->mat[ts[index].init2.x-1][ts[index].init2.y].type != 'X' && ts[index].init2.x < SO_WIDTHS && ts[index].init2.x > arrivo.x){
result[i].x = ts[index].init2.x-1;
result[i].y = ts[index].init2.y;
i++;
}else if(mat->mat[ts[index].init2.x][ts[index].init2.y-1].type != 'X' && ts[index].init2.y < SO_HEIGHT && ts[index].init2.y > arrivo.y){
result[i].x = ts[index].init2.x;
result[i].y = ts[index].init2.y-1;
i++;
}
result[i].x = -1;
result[i].y = -1;
if(ts[index].init2.x == arrivo.x && ts[index].init2.y == arrivo.y)
arrivato = 1;
}
return result;
}
int contaPercorso(coordinate percorso){
int percorsoTot;
int i = 0;
int j = 0;
for(i = 0;i<percorso.x;i++){
for(j = 0;j<percorso.y;j++){
percorsoTot+1;
}
}
return percorsoTot;
}
void movimento_taxi(coordinate cord,coordinate cord2,matrix *mat,taxi *ts)
{
printf("SONO IN MOVIMENTO_TAXI \n");
printf("Taxi %d \n",getpid());
printf("Message received : 1x %d 1y %d and 2x %d 2y %d\n",cord.x,cord.y,cord2.x,cord2.y);
int i = 0;
int j = 0;
int a = 0;
taxi vicino;
int trovato;
while(!trovato){
int id;
int a1 = 0;
int a2 = 0;
coordinate* per1[SO_HEIGHT * SO_WIDTHS] = percorso(ts, cord, mat,a);
if(ts[a+1] != NULL){
coordinate per2[] = percorso(ts, cord, mat,a+1);
a1 = contaPercorso(per1);
a2 = contaPercorso(per2);
}
if(a1 < a2) {
vicino = ts[a];
}
}
//printf("ID= %d (CHILD): PROCESSID=%d, Taxi creato coord : x %d y: %d\n",ts[a].ID, ts[a].processID,ts[a].init2.x,ts[a].init2.y);
// Controllo quale è il piu vicino, salvo id taxi = ts[i];
//coordinate percorso[] = percorso(vicino, cord, mat, /*int id taxi vicino*/);
// Da qui controllo sul percorso, celle libere ovvero ci sta il taxi
for (i = 0; i < SO_HEIGHT; i++)
{
//printf("Taxi %d è qui\n",getpid());
for (j = 0; j < SO_WIDTHS; j++)
{
if(mat->mat[i][j].type == '1' || mat->mat[i][j].type == '2' || mat->mat[i][j].type == '3')
{
printf("Taxi %d è qui\n",getpid());
}
}
}
printf("ESCO DA MOVIMENTO_TAXI \n");
//printf("semaforo unlocked %d \n",&sops);
//UNLOCK;
}
Anonymous
;-;
Chr
What is database admin utilities
Chr
How can we write in c language
Chr
Any one help me
Simone
I can't return result[] in method "percorso". I have an error here oordinate* per1[SO_HEIGHT * SO_WIDTHS] = percorso(ts, cord, mat,a);
if(ts[a+1] != NULL){
coordinate per2[] = percorso(ts, cord, mat,a+1);
a1 = contaPercorso(per1);
a2 = contaPercorso(per2);
}
if(a1 < a2) {
vicino = ts[a];
}
Simone
If I take result of percorso method I have error in; cordinate* per1[SO_HEIGHT * SO_WIDTHS] = percorso(ts, cord, mat,a);
Simone
Sry for very bad english
Igor🇺🇦
Simone
So i can insert this value and move the taxi
Simone
Massi
Hello guys any tips for learning C and books to read?
Diego
/get cbook
Massi
/get
Massi
/get cbook
Massi
thank you so much king
Avique
in c++, If i initialize object variables outside the constructor, will it be equivalent to do these operations at runtime, "manually"?
For example, for this class:
class AClass()
{
public:
AClass()
{
}
private:
int t[16] = { 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0 };
int n = 0;
int p = 0;
[...] // class funcions
}
Vlad
in c++, If i initialize object variables outside the constructor, will it be equivalent to do these operations at runtime, "manually"?
For example, for this class:
class AClass()
{
public:
AClass()
{
}
private:
int t[16] = { 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0 };
int n = 0;
int p = 0;
[...] // class funcions
}
It will convert it to the default constructor with init list that does all of the above
Vlad
Vlad
The only difference is "when"
Vlad
Init list is executed before getting into the body of the constructor
Avique
Vlad
Vlad
class Foo
{
static constexpr int bar = 42;
};
Avique
Ever learnt what static's do? :P
yes, i have, long ago - i forgot exactly what it is. so, i refreshed about it here:
https://www.geeksforgeeks.org/static-keyword-cpp/
And static variables or properties would not be good here.
Vlad
Vlad
Are you just fond of storing constants in EACH object for no reason?
Vlad
Vlad
No. You assign it once on creation of an object
Anonymous
/get cppbookguide
Anonymous
Hello, I can get where to study program in c or a book?
klimi
Y
Hello! Can anyone help me building GitHub repo via qt. I'm completely new to cpp. (I don't know any code and I'm banging my head on Google and stack overflow just to find the solution...then one friend recommended to search in on telegram).
Repo is opensource and I can share link privately if someone want to help me..🥺
olli
Y
SetPf
Hello. How i must make copy constructor for a struct with anonymous union?
Anonymous
Thank you
Pavel
SetPf
I use this structs only for data encapsulation, nothing more.
struct Device::Value
{
const char* const as_string;
union {
uint8_t as_byte;
union {
int32_t as_int;
uint32_t as_uint;
uint8_t as_array[4];
};
union {
uint16_t as_word;
struct {
uint8_t lsb;
uint8_t msb;
}as_bytes;
};
};
~Value(){
if(as_string) { delete as_string; }
}
};
SetPf
Yeah it hard shitty coded =)
Pavel
Nils
SetPf
Anonymous
Hello, could anyone suggest me a good book recommendation? I am looking for something like "Control electronic C ++ devices Yanta Catupitia Kim Bentley" pleeese