Ravi
C++ is the superset of C, i.e. C++ is derrived from C, and have made certain changes
AJAY
AJAY
class Person(Skills): name = str("Ankush Bhagat")
Anonymous
class Person(Skills): name = str("Ankush Bhagat")
Yes but how did I print a string after whitespace
class Person(Skills): name = str("Ankush Bhagat")
Hello World
.../
World
Anonymous
Shourya
What is the difference between c and c++
Well ..There are many differences in c and c++...c++ is more of a multi paradigm language..As it supports oops so it gives you power full concept of interfaces that can change the order of dependencies..Watch this Uncle bob lecture...From 12 mins onwards...https://www.youtube.com/watch?v=zHiWqnTWsn4 before explaining SOLID Principles he gives an idea of what c++ provides and procedural programing don't...Bit lengthy but trust me totally worth..
Shourya
Anonymous
Anonymous
is this somehow unreadable?
Anonymous
clang
a.cpp:37:14: error: unexpected ':' in nested name specifier; did you mean '::'?
void student : read() {
^
::
a.cpp:45:14: error: unexpected ':' in nested name specifier; did you mean '::'?
void student : display() {
^
::
Anonymous
Aditi
any one help for vaccine distribution
HaiNahi
5*8-(3*(1+4)+4)/(4*(5+2)) my calculator solved this ^^ tail recursion
Anonymous
Apk
RITESH
Sandeep
#include <bits/stdc++.h>
using namespace std;
void swap(int& a, int& b)
{
int temp = a;
a = b;
b = temp;
}
void rotate(int a[], int n, int idx)
{
int i;
for (i = 0; i < idx / 2; i++)
swap(a[i], a[idx - 1 - i]);
for (i = idx; i < (n + idx) / 2; i++)
swap(a[i], a[n - 1 - (i - idx)]);
for (i = 0; i < n / 2; i++)
swap(a[i], a[n - 1 - i]);
}
void sol(int a1[], int a2[], int n, int m)
{
int l = 0, h = n - 1, idx = 0;👈👈👈👈what is idx significance anybody
//---------------------------------------------------------
while (l <= h) {
// select the median of the remaining subarray
int c1 = (l + h) / 2;
// select the first elements from the larger array
// euqal to the size of remaining portion to the
// right of the smaller array
int c2 = n - c1 - 1;
int l1 = a1[c1];
int l2 = a2[c2 - 1];
int r1 = c1 == n - 1 ? INT_MAX : a1[c1 + 1];
int r2 = c2 == m ? INT_MAX : a2[c2];
// compare the border elements and check for the
// target index
if (l1 > r2) {
h = c1 - 1;
if (h == -1)
idx = 0;
}
else if (l2 > r1) {
l = c1 + 1;
if (l == n - 1)
idx = n;
}
else {
idx = c1 + 1;
break;
}
}
for (int i = idx; i < n; i++)
swap(a1[i], a2[i - idx]);
sort(a1, a1 + n);
sort(a2, a2 + m);
}
void merge(int arr1[], int arr2[], int n, int m)
{
// code here
if (n > m) {
sol(arr2, arr1, m, n);
rotate(arr1, n, n - m);
for (int i = 0; i < m; i++)
swap(arr2[i], arr1[i]);
}
else {
sol(arr1, arr2, n, m);
}
}
int main()
{
int ar1[] = { 1, 5, 9, 10, 15, 20 };
int ar2[] = { 2, 3, 8, 13 };
int m = sizeof(ar1) / sizeof(ar1[0]);
int n = sizeof(ar2) / sizeof(ar2[0]);
merge(ar1, ar2, m, n);
cout << "After Merging \nFirst Array: ";
for (int i = 0; i < m; i++)
cout << ar1[i] << " ";
cout << "\nSecond Array: ";
for (int i = 0; i < n; i++)
cout << ar2[i] << " ";
return 0;
}
Sandeep
#include <bits/stdc++.h>
using namespace std;
void swap(int& a, int& b)
{
int temp = a;
a = b;
b = temp;
}
void rotate(int a[], int n, int idx)
{
int i;
for (i = 0; i < idx / 2; i++)
swap(a[i], a[idx - 1 - i]);
for (i = idx; i < (n + idx) / 2; i++)
swap(a[i], a[n - 1 - (i - idx)]);
for (i = 0; i < n / 2; i++)
swap(a[i], a[n - 1 - i]);
}
void sol(int a1[], int a2[], int n, int m)
{
int l = 0, h = n - 1, idx = 0;👈👈👈👈what is idx significance anybody
//---------------------------------------------------------
while (l <= h) {
// select the median of the remaining subarray
int c1 = (l + h) / 2;
// select the first elements from the larger array
// euqal to the size of remaining portion to the
// right of the smaller array
int c2 = n - c1 - 1;
int l1 = a1[c1];
int l2 = a2[c2 - 1];
int r1 = c1 == n - 1 ? INT_MAX : a1[c1 + 1];
int r2 = c2 == m ? INT_MAX : a2[c2];
// compare the border elements and check for the
// target index
if (l1 > r2) {
h = c1 - 1;
if (h == -1)
idx = 0;
}
else if (l2 > r1) {
l = c1 + 1;
if (l == n - 1)
idx = n;
}
else {
idx = c1 + 1;
break;
}
}
for (int i = idx; i < n; i++)
swap(a1[i], a2[i - idx]);
sort(a1, a1 + n);
sort(a2, a2 + m);
}
void merge(int arr1[], int arr2[], int n, int m)
{
// code here
if (n > m) {
sol(arr2, arr1, m, n);
rotate(arr1, n, n - m);
for (int i = 0; i < m; i++)
swap(arr2[i], arr1[i]);
}
else {
sol(arr1, arr2, n, m);
}
}
int main()
{
int ar1[] = { 1, 5, 9, 10, 15, 20 };
int ar2[] = { 2, 3, 8, 13 };
int m = sizeof(ar1) / sizeof(ar1[0]);
int n = sizeof(ar2) / sizeof(ar2[0]);
merge(ar1, ar2, m, n);
cout << "After Merging \nFirst Array: ";
for (int i = 0; i < m; i++)
cout << ar1[i] << " ";
cout << "\nSecond Array: ";
for (int i = 0; i < n; i++)
cout << ar2[i] << " ";
return 0;
}
This program is for merging two sorted arrays without extra space
Anonymous
Can anyone tell me a good example of multiple inheritance which is easy and we can understand
Multiple inheritance is usually used to refer to the cases where a class derives from 2 or more base classes directly. What you have is just plain inheritance down to multiple levels which is not essentially the same. AFAIK in 6 years of professional development I have not seen code where multiple inheritanceis used. Most of the times when duck typing needs to be emulated, C++ programmers usually choose what Java developers do. Inherit interfaces.
Most of the code out there instead uses composition and aggregation to model relationships.
Sandeep
Anonymous
Table= (int**)calloc(rowNum+1, sizeof(int*));
I am trying to figure out what is diffrence in pointers to int* and int** in above dynamic ragged array code?
Ravi
Ravi
Anonymous
Anonymous
Ravi
Ravi
Anonymous
so int* and int** both point to Zeroth row and coloum?
Int** points to an array of int* pointers. It doesnt point to the element in the zeroth row and zeroth column. The first int* pointer after it is made to point to allocated memory will point to the first element in the array that it is pointing to. And in your Original post you mentioned it is a jagged array. So there is no concept of rows and columns. If all the int* pointers point to arrays of the same size, then the first int* pointer will point to the element in 0th row and zeroth column.
Anonymous
Anonymous
Anonymous
Anonymous
please use malloc
Anonymous
please use malloc
U mentioned 2d arrays = int**. You didnt mention malloc there.
Anonymous
Sandeep
Sandeep
/warn @MissRose_bot wtf
klimi
Picky
Is there anyone who can give me any online works? Actually I have to bear my University cost so i have to work plz
Ram saran
Urgent C2C Requirements
Peoplesoft Financials Functional Analyst 2
Location:Austin Texas
Client: State of Texas
-----------------------
ETL/SQL Developer
Piscataway NJ / Harrison NY.
Only H4EAD , GC , USC
Exp: 8 Years Minimum
Primarily having good SSIS experience and also strong on SQL and Data Analysis
--------------------------
Program and Project Manager @ Remote
Minimum 10+ YEARS exp Only
3+ experience working hands-on with AWS and/or other cloud hosting providers.- Must
----------------------------
Sr AEM Developer for Palo Alto, CA
12+ months contract
Need Local candidates or candidates who will genuinely relocate immediately.
-----------------------------
Please share Profile to ram@tekwings.com
Anonymous
PREM SAGAR
Mr.007, [28.06.21 23:33]
Mr.007, [28.06.21 22:47]
#include<iostream.h>
#include<conio.h>
#include<dos.h>
#include<stdlib.h>
#include<graphics.h>
#define LEFT 75
#define RIGHT 77
#define UP 72
#define DOWN 80
#define ENTER 13
class CAR
{
public:
int cp, init, op1, op2, op3; //initializing car,and obstacles
CAR::CAR() //creating constructor for the class car
{
cp = 300; //putting car value at 300
init = 0;
op1 = 0; //1st obstacle starts from 0
op2 = -20; //2nd obstacle starts 20 behind the 1st obstacle
op3 = -40; //3rd one starts 40 behind the 1st one
}
}
car; //object
int randx( void ) //creating function for random obstacle appearance
{
int x = random( 55*8 );//using random function to choose a random valuefor random obstacle
if ( x < 25*8 )//if the x axis distance is less then 25 the obstacle lies outside the lane
{
x = x + ( 25 *8 );//so we add 25 to keep the values in the lane
}
return ( x );
}
void right() //this is called to perform right dirn movement
{
if ( car.cp < 420 ) //here the class object is compared
{
car.cp += 10;//to move the car from 10 dirn
}
return ;
}
void left() //this is for left dirn
{
if ( car.cp > 180 ) //for left movement
{
car.cp -= 10;
}
return ;
}
void bgmove() //car body and its movement
{
if ( car.init > 5 )
{
car.init = 1;//init set to one
}
setcolor( RED ); //car body
setfillstyle( SOLID_FILL,WHITE );//fills the block into colour assigned
sector( car.cp + 20, 330, 0, 180, 20, 30 );//formation of ellipse head of car
setfillstyle( SOLID_FILL,RED );
bar3d( car.cp, 333, car.cp + 37, 360, 4, 4 );//function to create a block i.e. looks as a cube
for ( int i = car.init;i < 70;i += 5 )//for the design of lane
{
setcolor(BLUE );
setfillstyle( 1, BLUE );
bar( 16 * 8, i * 8, 20 * 8, ( i + 2 ) * 8 );//creating walls forming at side of road
bar( 60 * 8, i * 8, 64 * 8, ( i + 2 ) * 8 );
}
return ;
}
void opp1( int x1 )//obstacle 1
{
if ( car.op1 < 600 )
{
car.op1 += 10;
setfillstyle( 1, RED );
bar3d( x1, car.op1, x1 + 30, car.op1 + 30, 2, 3 );
}
else
{
car.op1 = 0;
}
return ;
}
void opp2( int x2 )//obstacle 2
{
if ( car.op2 < 600 )
{
car.op2 += 10;
setfillstyle( 1, YELLOW );
bar3d( x2, car.op2, x2 + 30, car.op2 + 30, 2, 3 );
}
else
{
car.op2 = 0;
}
return ;
}
void opp3( int x3 ) //obstacle 3
{
if ( car.op3 < 600 )
{
car.op3 += 10;
setfillstyle( 1, BLUE );
bar3d( x3, car.op3, x3 + 30, car.op3 + 30, 2, 3 );
}
else
{
car.op3 = 0;
}
return ;
}
int check( int x, int op, int cp ) //collision part
{
int a[ 31 ], b[ 31 ], c[ 40 ], d[ 50 ];//let the sizes randomly or just let according to loop
for ( int i = 0;i < 30;i++ )
{
a[ i ] = x + i; //random value suppled + i using loop
}
for ( i = 0;i < 30;i++ )
{
b[ i ] = op + i;//returned obstacle value
}
for ( i = 0;i < 40;i++ )
{
c[ i ] = cp + i; //returned car value
}
PREM SAGAR
Mr.007, [28.06.21 23:33]
Mr.007, [28.06.21 22:47]
for ( i = 0;i < 50;i++ )
{
d[ i ] = 300 + i; //
}
for ( i = 0;i < 40;i++ )
{
for ( int j = 0;j < 50;j++ )
{
for ( int k = 0;k < 30;k++ )
{
if ( a[ k ] == c[ i ] && b[ k ] == d[ j ] )
return 1;
}
}
}
return 0;
}
PREM SAGAR
void logo ()
{
for ( int i = 1;i < 250;i++ ) //for the introduction part
{
int p;
setcolor( YELLOW );
setfillstyle( SOLID_FILL, LIGHTBLUE );
settextstyle( 7, HORIZ_DIR, 5 );
outtextxy( 65, 100,"HCOE GRAPHICS PROJECT" );
outtextxy(150,150 ," RACING GAME " );
outtextxy(150,200," 070 BCT B ");
setcolor( WHITE );
settextstyle( 2, HORIZ_DIR, 5 );
outtextxy(150,250, "PRESENTED TO : DEPARTMENT OF ELECTRONICS AND COMPUTER " );
outtextxy(150,300, "PRESENTED BY : ROLL NOS (48,50,52,57,64)");
}
delay( 2000 );
cleardevice();
return ;
}
void over( void )//after collision this is to show the game over
{
for ( int i = 1;i < 35;i++ )
{
cleardevice();
delay( 20 );
settextstyle( 1, 0, 6 );
setcolor( RED );
outtextxy( 150, 100, "!!!GAME OVER!!!" );
delay( 20 );
}
delay( 2000 );
cleardevice();
getch();
return ;
}
void about() //menu part and control the menu
{
while ( !kbhit() )
{
for ( int i = 300;kbhit() == 0;i++ )
{
cleardevice();
setcolor( 6 );
settextstyle( 2, 0, 6 );
outtextxy( 600 - i, 600 - i, "season maharjan(48)" );
outtextxy( i - 150, 215, "yaju shrestha(64)" );
outtextxy( i - 30, i - 130, "smriti mool(52)" );
outtextxy( 600 - i, i - 150, "shiwangi shrestha(50)" );
outtextxy( 600 -i, i -300 , "sushmita chaurasia(57)" );
setfillstyle( 1, 4 );
setcolor( 1 );
settextstyle( 2, 0, 10 );
outtextxy( 280, 380, "HCOE" );
outtextxy( 215, 420, "O70 BATCH" );
delay( 60 );
}
}
getch();
return ;
}
\
PREM SAGAR
int play( void )//if the play is entered by user
{
int life = 1, m, x1, x2, x3, s;//assigning values for life, m for selection
//x1,x2,x3 for random values from the randx function
re:
while ( life ) //check the life value to enter the while loop
{
cleardevice();
if ( car.op1 == 0 ) //
{
x1 = randx();//getting the random values
car.op1++;//calling the obstacle in class and incrementing
}
else
{
opp1( x1 );//if not equal to zero print the obstacle
}
if ( car.op2 == 0 )//for obstacle 2
{
x2 = randx();
car.op2++;
}
else if ( car.op2 < 1 ) //for obstacle valueless than 1
{
car.op2++;
}
else
{
opp2( x2 );
}
if ( car.op3 == 0 ) //for obstacle no 3
{
x3 = randx();
car.op3++;
}
else if ( car.op3 < 1 )
{car.op3++;}
else
{
opp3( x3 );
}
setcolor( 10 );
bgmove(); //calling move function for car to appearin sceen
if ( check( x2, car.op2, car.cp ) || check( x1, car.op1, car.cp ) || check( x3, car.op3, car.cp ) )
{ //checking the collision condition from the check function
life--;
if ( life == 0 )
{
over();//calling the over fuction for finishing the game
}
car.op1 = 1; //initializing the obstacle
car.op2 = -16;
car.op3 = -32;
goto re;//using goto to repeat the processes always
}
if ( kbhit() )//check the key stroke
{
m = getch();
switch ( m ) //key stroke decision using switch case
{
case LEFT: left();//for left arrow
break;
case RIGHT: right(); //for right arrow key
break;
case 'q': exit( 0 ); //to exit the game when ever the user want to
}
}
else
{
delay( 100 );
}
}
getch();
return ( 0 );
}
void menu()//for the menu appearance
{
int s = 1, t = 0, a, p = 140;//here s is for keystroke selection in switch case
do//to contiue the program after finish
{ //here a is for the rectangle to move up and down
do //p for rectangle use in menu
{
cleardevice();
setcolor( YELLOW );
settextstyle( 1, 0, 4 );
outtextxy( 230, 30, "MENU" );Mr.007, [28.06.21 23:33]
Mr.007, [28.06.21 22:47]
PREM SAGAR
for ( i = 0;i < 50;i++ )
{
d[ i ] = 300 + i; //
}
for ( i = 0;i < 40;i++ )
{
for ( int j = 0;j < 50;j++ )
{
for ( int k = 0;k < 30;k++ )
{
if ( a[ k ] == c[ i ] && b[ k ] == d[ j ] )
return 1;
}
}
}
return 0;
}
PREM SAGAR
void logo ()
{
for ( int i = 1;i < 250;i++ ) //for the introduction part
{
int p;
setcolor( YELLOW );
setfillstyle( SOLID_FILL, LIGHTBLUE );
settextstyle( 7, HORIZ_DIR, 5 );
outtextxy( 65, 100,"HCOE GRAPHICS PROJECT" );
outtextxy(150,150 ," RACING GAME " );
outtextxy(150,200," 070 BCT B ");
setcolor( WHITE );
settextstyle( 2, HORIZ_DIR, 5 );
outtextxy(150,250, "PRESENTED TO : DEPARTMENT OF ELECTRONICS AND COMPUTER " );
outtextxy(150,300, "PRESENTED BY : ROLL NOS (48,50,52,57,64)");
}
delay( 2000 );
cleardevice();
return ;
}
void over( void )//after collision this is to show the game over
{
for ( int i = 1;i < 35;i++ )
{
cleardevice();
delay( 20 );
settextstyle( 1, 0, 6 );
setcolor( RED );
outtextxy( 150, 100, "!!!GAME OVER!!!" );
delay( 20 );
}
delay( 2000 );
cleardevice();
getch();
return ;
}
void about() //menu part and control the menu
{
while ( !kbhit() )
{
for ( int i = 300;kbhit() == 0;i++ )
{
cleardevice();
setcolor( 6 );
settextstyle( 2, 0, 6 );
outtextxy( 600 - i, 600 - i, "season maharjan(48)" );
outtextxy( i - 150, 215, "yaju shrestha(64)" );
outtextxy( i - 30, i - 130, "smriti mool(52)" );
outtextxy( 600 - i, i - 150, "shiwangi shrestha(50)" );
outtextxy( 600 -i, i -300 , "sushmita chaurasia(57)" );
setfillstyle( 1, 4 );
setcolor( 1 );
settextstyle( 2, 0, 10 );
outtextxy( 280, 380, "HCOE" );
outtextxy( 215, 420, "O70 BATCH" );
delay( 60 );
}
}
getch();
return ;
}
int play( void )//if the play is entered by user
{
int life = 1, m, x1, x2, x3, s;//assigning values for life, m for selection
//x1,x2,x3 for random values from the randx function
re:
while ( life ) //check the life value to enter the while loop
{
cleardevice();
if ( car.op1 == 0 ) //
{
x1 = randx();//getting the random values
car.op1++;//calling the obstacle in class and incrementing
}
else
{
opp1( x1 );//if not equal to zero print the obstacle
}
if ( car.op2 == 0 )//for obstacle 2
{
x2 = randx();
car.op2++;
}
else if ( car.op2 < 1 ) //for obstacle valueless than 1
{
car.op2++;
}
else
{
opp2( x2 );
}
if ( car.op3 == 0 ) //for obstacle no 3
{
x3 = randx();
car.op3++;
}
else if ( car.op3 < 1 )
{car.op3++;}
else
{
opp3( x3 );
}
setcolor( 10 );
bgmove(); //calling move function for car to appearin sceen
if ( check( x2, car.op2, car.cp ) || check( x1, car.op1, car.cp ) || check( x3, car.op3, car.cp ) )
{ //checking the collision condition from the check function
life--;
if ( life == 0 )
{
over();//calling the over fuction for finishing the game
}
car.op1 = 1; //initializing the obstacle
car.op2 = -16;
car.op3 = -32;
goto re;//using goto to repeat the processes always
}
if ( kbhit() )//check the key stroke
{
m = getch();
switch ( m ) //key stroke decision using switch case
{
case LEFT: left();//for left arrow
break;
case RIGHT: right(); //for right arrow key
break;
case 'q': exit( 0 ); //to exit the game when ever the user want to
}
}
else
{
delay( 100 );
}
}
getch();
return ( 0 );
}
PREM SAGAR
void menu()//for the menu appearance
{
int s = 1, t = 0, a, p = 140;//here s is for keystroke selection in switch case
do//to contiue the program after finish
{ //here a is for the rectangle to move up and down
do //p for rectangle use in menu
{
cleardevice();
setcolor( YELLOW );
settextstyle( 1, 0, 4 );
outtextxy( 230, 30, "MENU" )
artemetra 🇺🇦
void logo ()
{
for ( int i = 1;i < 250;i++ ) //for the introduction part
{
int p;
setcolor( YELLOW );
setfillstyle( SOLID_FILL, LIGHTBLUE );
settextstyle( 7, HORIZ_DIR, 5 );
outtextxy( 65, 100,"HCOE GRAPHICS PROJECT" );
outtextxy(150,150 ," RACING GAME " );
outtextxy(150,200," 070 BCT B ");
setcolor( WHITE );
settextstyle( 2, HORIZ_DIR, 5 );
outtextxy(150,250, "PRESENTED TO : DEPARTMENT OF ELECTRONICS AND COMPUTER " );
outtextxy(150,300, "PRESENTED BY : ROLL NOS (48,50,52,57,64)");
}
delay( 2000 );
cleardevice();
return ;
}
void over( void )//after collision this is to show the game over
{
for ( int i = 1;i < 35;i++ )
{
cleardevice();
delay( 20 );
settextstyle( 1, 0, 6 );
setcolor( RED );
outtextxy( 150, 100, "!!!GAME OVER!!!" );
delay( 20 );
}
delay( 2000 );
cleardevice();
getch();
return ;
}
void about() //menu part and control the menu
{
while ( !kbhit() )
{
for ( int i = 300;kbhit() == 0;i++ )
{
cleardevice();
setcolor( 6 );
settextstyle( 2, 0, 6 );
outtextxy( 600 - i, 600 - i, "season maharjan(48)" );
outtextxy( i - 150, 215, "yaju shrestha(64)" );
outtextxy( i - 30, i - 130, "smriti mool(52)" );
outtextxy( 600 - i, i - 150, "shiwangi shrestha(50)" );
outtextxy( 600 -i, i -300 , "sushmita chaurasia(57)" );
setfillstyle( 1, 4 );
setcolor( 1 );
settextstyle( 2, 0, 10 );
outtextxy( 280, 380, "HCOE" );
outtextxy( 215, 420, "O70 BATCH" );
delay( 60 );
}
}
getch();
return ;
}
int play( void )//if the play is entered by user
{
int life = 1, m, x1, x2, x3, s;//assigning values for life, m for selection
//x1,x2,x3 for random values from the randx function
re:
while ( life ) //check the life value to enter the while loop
{
cleardevice();
if ( car.op1 == 0 ) //
{
x1 = randx();//getting the random values
car.op1++;//calling the obstacle in class and incrementing
}
else
{
opp1( x1 );//if not equal to zero print the obstacle
}
if ( car.op2 == 0 )//for obstacle 2
{
x2 = randx();
car.op2++;
}
else if ( car.op2 < 1 ) //for obstacle valueless than 1
{
car.op2++;
}
else
{
opp2( x2 );
}
if ( car.op3 == 0 ) //for obstacle no 3
{
x3 = randx();
car.op3++;
}
else if ( car.op3 < 1 )
{car.op3++;}
else
{
opp3( x3 );
}
setcolor( 10 );
bgmove(); //calling move function for car to appearin sceen
if ( check( x2, car.op2, car.cp ) || check( x1, car.op1, car.cp ) || check( x3, car.op3, car.cp ) )
{ //checking the collision condition from the check function
life--;
if ( life == 0 )
{
over();//calling the over fuction for finishing the game
}
car.op1 = 1; //initializing the obstacle
car.op2 = -16;
car.op3 = -32;
goto re;//using goto to repeat the processes always
}
if ( kbhit() )//check the key stroke
{
m = getch();
switch ( m ) //key stroke decision using switch case
{
case LEFT: left();//for left arrow
break;
case RIGHT: right(); //for right arrow key
break;
case 'q': exit( 0 ); //to exit the game when ever the user want to
}
}
else
{
delay( 100 );
}
}
getch();
return ( 0 );
}
/report
Dima
What the heck
PREM SAGAR
/report
please i have doubt plez
PREM SAGAR
PREM SAGAR
please
PREM SAGAR
PREM SAGAR
now brother
Golden Age Of
PREM SAGAR
tq brother
ram
Thank You @ravi
ram
https://codeforces.com/contest/1535/problem/B
ram
#include<bits/stdc++.h>
using namespace std;
int gcd(int a, int b)
{
if (b == 0)
return a;
return gcd(b, a % b);
}
int main()
{
int t,n,ev=0,num,ans=0;
vector <int> vec;
cin >>t ;
while(t--)
{
cin >> n;
for(int no=0;no<n;no++)
{
cin >> num;
if(num%2==0)
{
ans=ans+n-1-ev;
ev++;
}
else
vec.push_back(num);
}
for(int no=0;no<vec.size()-1;no++)
{
for(int no1=no+1;no1<vec.size();no1++)
if(gcd(vec[no],vec[no1])>1)
ans++;
}
cout << ans<<"\n";
ans=0;
ev=0;
vec.clear();
}
}
ram
I am getting time limit exceeded
Anonymous
void logo ()
{
for ( int i = 1;i < 250;i++ ) //for the introduction part
{
int p;
setcolor( YELLOW );
setfillstyle( SOLID_FILL, LIGHTBLUE );
settextstyle( 7, HORIZ_DIR, 5 );
outtextxy( 65, 100,"HCOE GRAPHICS PROJECT" );
outtextxy(150,150 ," RACING GAME " );
outtextxy(150,200," 070 BCT B ");
setcolor( WHITE );
settextstyle( 2, HORIZ_DIR, 5 );
outtextxy(150,250, "PRESENTED TO : DEPARTMENT OF ELECTRONICS AND COMPUTER " );
outtextxy(150,300, "PRESENTED BY : ROLL NOS (48,50,52,57,64)");
}
delay( 2000 );
cleardevice();
return ;
}
void over( void )//after collision this is to show the game over
{
for ( int i = 1;i < 35;i++ )
{
cleardevice();
delay( 20 );
settextstyle( 1, 0, 6 );
setcolor( RED );
outtextxy( 150, 100, "!!!GAME OVER!!!" );
delay( 20 );
}
delay( 2000 );
cleardevice();
getch();
return ;
}
void about() //menu part and control the menu
{
while ( !kbhit() )
{
for ( int i = 300;kbhit() == 0;i++ )
{
cleardevice();
setcolor( 6 );
settextstyle( 2, 0, 6 );
outtextxy( 600 - i, 600 - i, "season maharjan(48)" );
outtextxy( i - 150, 215, "yaju shrestha(64)" );
outtextxy( i - 30, i - 130, "smriti mool(52)" );
outtextxy( 600 - i, i - 150, "shiwangi shrestha(50)" );
outtextxy( 600 -i, i -300 , "sushmita chaurasia(57)" );
setfillstyle( 1, 4 );
setcolor( 1 );
settextstyle( 2, 0, 10 );
outtextxy( 280, 380, "HCOE" );
outtextxy( 215, 420, "O70 BATCH" );
delay( 60 );
}
}
getch();
return ;
}
int play( void )//if the play is entered by user
{
int life = 1, m, x1, x2, x3, s;//assigning values for life, m for selection
//x1,x2,x3 for random values from the randx function
re:
while ( life ) //check the life value to enter the while loop
{
cleardevice();
if ( car.op1 == 0 ) //
{
x1 = randx();//getting the random values
car.op1++;//calling the obstacle in class and incrementing
}
else
{
opp1( x1 );//if not equal to zero print the obstacle
}
if ( car.op2 == 0 )//for obstacle 2
{
x2 = randx();
car.op2++;
}
else if ( car.op2 < 1 ) //for obstacle valueless than 1
{
car.op2++;
}
else
{
opp2( x2 );
}
if ( car.op3 == 0 ) //for obstacle no 3
{
x3 = randx();
car.op3++;
}
else if ( car.op3 < 1 )
{car.op3++;}
else
{
opp3( x3 );
}
setcolor( 10 );
bgmove(); //calling move function for car to appearin sceen
if ( check( x2, car.op2, car.cp ) || check( x1, car.op1, car.cp ) || check( x3, car.op3, car.cp ) )
{ //checking the collision condition from the check function
life--;
if ( life == 0 )
{
over();//calling the over fuction for finishing the game
}
car.op1 = 1; //initializing the obstacle
car.op2 = -16;
car.op3 = -32;
goto re;//using goto to repeat the processes always
}
if ( kbhit() )//check the key stroke
{
m = getch();
switch ( m ) //key stroke decision using switch case
{
case LEFT: left();//for left arrow
break;
case RIGHT: right(); //for right arrow key
break;
case 'q': exit( 0 ); //to exit the game when ever the user want to
}
}
else
{
delay( 100 );
}
}
getch();
return ( 0 );
}
Lmaoooo
Hermann
what is the difference between A a (p); and A {p};?. p is a struct
Igor🇺🇦
Hermann
Anonymous
what is the difference between A a (p); and A {p};?. p is a struct
A{p} can match a initializer_list constructor. A a(p) cannot.
struct P {
int p = 0;
};
struct A {
int a = 0;
A(P p) { cout << "1"; }
A(initializer_list<P> l) { cout << "2"; }
};
int main() {
P p;
A a(p);
A{p};
}
For example, this code will output "12".
Anonymous
I am getting time limit exceeded
Use GDB, you will find why you got TLE.
for(int no=0;no<vec.size()-1;no++) // vec.size() - 1 underflow if vec is empty