Anonymous
Anonymous
Anonymous
Nice! Well done :)
B121065_Swoyam Siddharth Nayak
#include<iostream>
#include<limits.h>
using namespace std;
int main(){
int n, max;
max=INT_MIN;
int origin[n];
for(int i=0;i<n;i++){
cin>>origin[i];
if(origin[i]>max){
max=origin[i];
}
}
int frequency[max+1]={0};
for(int i=0;i<n;i++){
frequency[origin[i]]++;
}
int temp=0;
int cummulative_frequency[max+1]={0};
for(int i=0;i<(max+1);i++){
cummulative_frequency[i]=temp+frequency[i];
temp=cummulative_frequency[i];
}
int sorted[n];
for(int i=0;i<n;i++){
int m=cummulative_frequency[origin[i]]-1;
sorted[m]=origin[i];
}
for(int i=0;i<n;i++){
cout<<sorted[i]<<" ";
}
return 0;
}
This is my program for count sort, where is the error, am getting no output
B121065_Swoyam Siddharth Nayak
Solved
B121065_Swoyam Siddharth Nayak
Count sort
Pitreedollar
Hello buddies
Pitreedollar
How do we test and ensure the function positive_or_negative() gives the correct output when given a case of 0.
Pitreedollar
ninja
this can't be your entire program?
ninja
what's the error
ninja
sry my English not good ... what is "go it"?
Anonymous
Anonymous
do it
Anonymous
[anyword] it
ninja
ninja
Anonymous
wide_t is data type?
Anonymous
Anonymous
int64_t is a macros too
Anonymous
type is autoselect by platform
Anonymous
Okay
™barynium†⋆。˚🇧🇷
Thanks
Sachin
#include<stdio.h>
int main( )
{
int n[3][3] = {
2, 4, 3,
6, 8, 5,
3, 5, 1
} ;
int i, *ptr ;
ptr = n ;
for ( i = 0 ; i <= 8 ; i++ )
printf ( "\n%d", *( ptr +i) ) ;
}
where is this ptr pointing ?
Sachin
where is this ptr pointing ?
Hanz
i think its n
Hanz
idk, im new
Ravi
True, its pointing to the starting address of matrix n that is first element
Ravi
But maybe array declaration should be like this,
#include<stdio.h>
int main( )
{
int n[3][3] = {
{2, 4, 3},
{6, 8, 5},
{3, 5, 1}
} ;
Anonymous
Hi guys there is any library or macro in C++ which will map GUI domain of simulation softwares and generate reports and graphs at run time based on programme
Anonymous
?
Anonymous
Anonymous
can u simply explain what's int grade[3] means ?
Ravi
grade[5] means the size of 5 will be allocated to grade array, but here, our requirement is only upto 3 so, 2*sizeof(int) memory will be wasted for this particular program
m
what is this error in qt 5.6.2 android »»»»The process tried to write to a nonexistent pipe
m
this error occured when build with ant
Luffy
can anyone suggest me a good resource or a course for learning STL
Luffy
i am currently learning it from cplusplus.com
Hanz
Hanz
Interactive learning 👆
Vlad
Anonymous
R
What is the output? main() { register int x = 5; int *p; p=&x; x++; print(*p); }
A. Error
B. 5
C. 6
D. Garbage value
Pavel
Anonymous
R
What is the output of the code given below static int data=5; void main() { int sum=0; do { sum=sum+data; } while(0< data--); print(sum); }
A. 5
B. 15
C. 14
D. Error
Anonymous
R
Anonymous
5
Why 5? I think it's 6.
R
workbook
Anonymous
workbook
Then run the code in your IDE...
R
Anonymous
Why 5? I think it's 6.
Its Post increment operator, and X is not called after increment. Directly pointer is referenced in next line so i think it is 5
R
Anonymous
120kbps speed lol
More than enough for executing in online if you don't have an offline one already...
Anonymous
Anonymous
Anonymous
Anonymous
120kbps speed lol
You can try compiler explorer. Its lightweight and great.
R
Sachin
#include <stdio.h>
struct student_info
{
char name[27];
int roll_no;
int submarks;
};
void enter(struct student_info s1)
{
printf("\nEnter the details of Student \n");
printf("Name:");
scanf(" %[^\n]s",s1.name) ;
printf("Roll Number:");
scanf("%d",&s1.roll_no) ;
printf("Marks in subject : ");
scanf("%d",&s1.submarks) ;
}
void display(struct student_info s2)
{
printf("\n\nName: %s", s2.name) ;
printf("\nRoll Number: %d", s2.roll_no) ;
printf("\nSubmarks: %d", s2.submarks) ;
}
int main()
{
struct student_info student;
enter(struct student_info student);
display(struct student_info student);
}
is me ky error hai?
Sachin
what is the errror?
Anonymous
Sachin
Sachin
#include <stdio.h>
struct student_info
{
char name[27];
int roll_no;
int submarks;
};
void enter(struct student_info *s1)
{
printf("\nEnter the details of Student \n");
printf("Name:");
scanf(" %[^\n]s",s1->name) ;
printf("Roll Number:");
scanf("%d",&s1->roll_no) ;
printf("Marks in subject : ");
scanf("%d",&s1->submarks) ;
}
void display(struct student_info s2)
{
printf("\n\nName: %s", s2.name) ;
printf("\nRoll Number: %d", s2.roll_no) ;
printf("\nSubmarks: %d", s2.submarks) ;
}
int main()
{
struct student_info student;
enter(&student);
display( student);
}
Sachin
can you tell me why enter is call by address and display is call by value
Sachin
?
Sachin
dislpay is call by value hence s2 variable will copy the content of student variable and then print them ?
Sachin
is m right