Manu
Whenever i try to take input ....it just show running in terminal
Ultima Filium
what's up people
Ultima Filium
how can assign the letters A to Z values of 1 to 26
Ultima Filium
such that A=1
and Z=26
'''''''
Alessandro
Ultima Filium
Ultima Filium
Mr
prog.cpp: In function ‘int NumberofElementsInIntersection(int*, int*, int, int)’:
prog.cpp:27:14: error: expected primary-expression before ‘int’
map<int,int> ma(ma.begin(),ma.end());
^
prog.cpp:29:13: error: ‘ma’ was not declared in this scope
ma[b[j]]++;
^~
prog.cpp:32:23: error: ‘ma’ was not declared in this scope
for ( auto j = ma.begin(); j != ma.end(); ++j)
^~
prog.cpp:40:14: error: expected primary-expression before ‘int’
map<int,int> m(m.begin(),m.end());
^
prog.cpp:42:13: error: ‘m’ was not declared in this scope
m[v[i]]++;
^
prog.cpp:45:13: error: ‘m’ was not declared in this scope
m[v1[i]]++;
^
prog.cpp:47:23: error: ‘m’ was not declared in this scope
for ( auto i = m.begin(); i != m.end(); ++i)
^
how to fixed it..
Mr
// { Driver Code Starts
// Initial template for C++
#include <bits/stdc++.h>
using namespace std;
int NumberofElementsInIntersection(int a[], int b[], int n, int o) {
// Your code goes here
int count = 0;
vector<int> v;
vector<int> v1;
map<int,int> map(map.begin(),
map.end());
for(int i = 0 ;i<n;i++){
map[a[i]]++;
}
for ( auto i = map.begin(); i != map.end(); ++i)
{
if(i->second >= 1){
v.push_back(i->first);
}
}
// map.clear();
map<int,int> ma(ma.begin(),ma.end());
for(int j = 0 ;j<o;j++){
ma[b[j]]++;
}
for ( auto j = ma.begin(); j != ma.end(); ++j)
{
if(j->second >= 1){
v1.push_back(j->first);
}
}
// ma.clear();
map<int,int> m(m.begin(),m.end());
for(int i = 0 ;i<v.size();i++){
m[v[i]]++;
}
for(int i = 0 ;i<v1.size();i++){
m[v1[i]]++;
}
for ( auto i = m.begin(); i != m.end(); ++i)
{
if(i->second > 1){
count++;
}
}
if(count==0){
return 0;
}
else{
return count;
}
}
// { Driver Code Starts.
int main() {
int t;
cin >> t;
while (t--) {
int n, o;
cin >> n >> o;
int a[n], b[o];
for (int i = 0; i < n; i++) cin >> a[i];
for (int i = 0; i < o; i++) cin >> b[i];
cout <<NumberofElementsInIntersection(a, b, n, o) << endl;
}
return 0;
}
Mr
// { Driver Code Starts
// Initial template for C++
#include <bits/stdc++.h>
using namespace std;
int NumberofElementsInIntersection(int a[], int b[], int n, int o) {
// Your code goes here
int count = 0;
vector<int> v;
vector<int> v1;
map<int,int> map(map.begin(),
map.end());
for(int i = 0 ;i<n;i++){
map[a[i]]++;
}
for ( auto i = map.begin(); i != map.end(); ++i)
{
if(i->second >= 1){
v.push_back(i->first);
}
}
// map.clear();
map<int,int> ma(ma.begin(),ma.end());
for(int j = 0 ;j<o;j++){
ma[b[j]]++;
}
for ( auto j = ma.begin(); j != ma.end(); ++j)
{
if(j->second >= 1){
v1.push_back(j->first);
}
}
// ma.clear();
map<int,int> m(m.begin(),m.end());
for(int i = 0 ;i<v.size();i++){
m[v[i]]++;
}
for(int i = 0 ;i<v1.size();i++){
m[v1[i]]++;
}
for ( auto i = m.begin(); i != m.end(); ++i)
{
if(i->second > 1){
count++;
}
}
if(count==0){
return 0;
}
else{
return count;
}
}
// { Driver Code Starts.
int main() {
int t;
cin >> t;
while (t--) {
int n, o;
cin >> n >> o;
int a[n], b[o];
for (int i = 0; i < n; i++) cin >> a[i];
for (int i = 0; i < o; i++) cin >> b[i];
cout <<NumberofElementsInIntersection(a, b, n, o) << endl;
}
return 0;
}
for this code..
Anonymous
// { Driver Code Starts
// Initial template for C++
#include <bits/stdc++.h>
using namespace std;
int NumberofElementsInIntersection(int a[], int b[], int n, int o) {
// Your code goes here
int count = 0;
vector<int> v;
vector<int> v1;
map<int,int> map(map.begin(),
map.end());
for(int i = 0 ;i<n;i++){
map[a[i]]++;
}
for ( auto i = map.begin(); i != map.end(); ++i)
{
if(i->second >= 1){
v.push_back(i->first);
}
}
// map.clear();
map<int,int> ma(ma.begin(),ma.end());
for(int j = 0 ;j<o;j++){
ma[b[j]]++;
}
for ( auto j = ma.begin(); j != ma.end(); ++j)
{
if(j->second >= 1){
v1.push_back(j->first);
}
}
// ma.clear();
map<int,int> m(m.begin(),m.end());
for(int i = 0 ;i<v.size();i++){
m[v[i]]++;
}
for(int i = 0 ;i<v1.size();i++){
m[v1[i]]++;
}
for ( auto i = m.begin(); i != m.end(); ++i)
{
if(i->second > 1){
count++;
}
}
if(count==0){
return 0;
}
else{
return count;
}
}
// { Driver Code Starts.
int main() {
int t;
cin >> t;
while (t--) {
int n, o;
cin >> n >> o;
int a[n], b[o];
for (int i = 0; i < n; i++) cin >> a[i];
for (int i = 0; i < o; i++) cin >> b[i];
cout <<NumberofElementsInIntersection(a, b, n, o) << endl;
}
return 0;
}
map<int,int> map(map.begin(),map end())
First map refers to a std::map in this code. You are now defining a variable called map in this block which hides the std::map type.
Second, you are using map.begin() and map.end() iterators to initialise a map which is just being defined. This is meaningless. You use this constructor only when you are trying to initialise a map from another map or a container of key value pairs.
VENUJAN
a number has 4 bytes but a char has 1 byte how?
VENUJAN
#include <stdio.h>
int main(){
int mark[] = {12,34,56,23,21};
mark[0]=3;
printf("%d",size);
return 0;
}
VENUJAN
and why i got 12 here?#include <stdio.h>
int main(){
char mark[] = "hello world";
int size = sizeof mark;
printf("%d",size);
return 0;
}
Golden Age Of
Mr
Markiyan
Hi,everyone,
I want to calculate this expression 2cos(y) + √sin^3(x) + log4 (sin(y) / (x^4 - y^4)) with these variables(x=0.894, y=13.464).
#include <stdio.h>
#include <math.h>
void main(void)
{
double x, y, z;
printf(“Enter variable x:”);
scanf(“%lf”, &x );
printf(“Enter variable y:”);
scanf(“%lf”, &y );
z=2*cos(y)+sqrt(pow(sin(x),3))+log(sin(y)/(pow(x,4)-pow(y,4)))/log(4.0);
printf(“Result: %lf ”, z);
}
I wrote this code, it compiles without errors, but when it comes to printing the result. It gives such output.
$ gcc test.c -lm
$ ./a.out
Enter variable x:0.894
Enter variable y:13.464
Result: -nan
What does this "-nan" mean?
My question is, is this a problem in given numbers or in my code?
olli
Hi,everyone,
I want to calculate this expression 2cos(y) + √sin^3(x) + log4 (sin(y) / (x^4 - y^4)) with these variables(x=0.894, y=13.464).
#include <stdio.h>
#include <math.h>
void main(void)
{
double x, y, z;
printf(“Enter variable x:”);
scanf(“%lf”, &x );
printf(“Enter variable y:”);
scanf(“%lf”, &y );
z=2*cos(y)+sqrt(pow(sin(x),3))+log(sin(y)/(pow(x,4)-pow(y,4)))/log(4.0);
printf(“Result: %lf ”, z);
}
I wrote this code, it compiles without errors, but when it comes to printing the result. It gives such output.
$ gcc test.c -lm
$ ./a.out
Enter variable x:0.894
Enter variable y:13.464
Result: -nan
What does this "-nan" mean?
My question is, is this a problem in given numbers or in my code?
nan is returned if a result cannot be expressed as a number, for your input the equation has no result since there is no log of a negative number
Markiyan
Markiyan
olli
Markiyan
looks good!
Thanks a lot, that was my main question. Strange thing with these numbers))
VENUJAN
#include <stdio.h>
int main(){
char inputData;
printf("Enter your string :");
scanf("%c",&inputData);
char str[] = inputData;
printf("%c",str[]);
}
VENUJAN
whats wrong
Melbourne Channel
how do i get my c program to use multicore automatically? is this possible?
GIDDY
How can I write a program to give me an output in descending order
Alessandro
Manu
VENUJAN
#include <stdio.h>
int main(){
int i,size;
char data[] = "ABCA123";
size = sizeof data;
for (i= 0;i<size-1;i++){
int box = data[i];
printf("%d\n",box);
if ((65 <= box <= 90))
{
printf("Alphabets\n");
}
}
}
VENUJAN
why its working for box values 49,50,51 ??
Pritam
I m facing an error of
No newline at end of file
Pritam
VENUJAN
Captain
Captain
Implement like this
Captain
#include <stdio.h>
int main(){
int i,size;
char data[] = "ABCA123";
size = sizeof data;
for (i= 0;i<size-1;i++){
int box = data[i];
printf("%d\n",box);
if ((65 <= box && box <= 90))
{
printf("Alphabets\n");
}
}
}
Anonymous
How to solve it
Two ways to solve it.
1. Upgrade your compiler or choose a more standard compliant compiler
2. Enter a new line manually at the end of each header file
Anonymous
Thank you so much
Vishal
Dhiraj
This message couldn't be displayed on your device due to copyright infringement.
touhou
Anonymous
ユセフ
Hi
Pavel
Use a condition variable They are meant just for this.
But for condition_variable I will need to also use a mutex and a bool, right?
In case that notify was called on the the condition variable by the producer thread before I started checking for it?
It feels like a bit of overhead (both more complex code and more work being done).
Pavel
Pavel
I guess I'm asking some not really correct questions, but I just want to understand what I'm doing to make better decisions by myself in future :)
Pavel
Anonymous
Who can help me with app I can use to learn programming frre
Anonymous
Varshan
https://www.programiz.com/cpp-programming/online-compiler/
Anonymous
Thanks again
Disha
i have a problem with my code
Disha
i need help bz i dont understand whats the problem
Disha
#include<stdio.h>
int main()
{
int n,arr[50],c=0,d=0;
printf("Enter the input number:");
scanf("%d",&n);
printf("Enter the elements of array:");
for(int i=0;i<n;i++)
{
scanf("%d",&arr[i]);
}
int max = arr[0];
for(int i=1;i<n;i++)
{
if(max<arr[i])
c++;
if(arr[0]=arr[i])
d++;
}
printf("%d numbers are greater than the first element",c);
printf("\n%d numbers of that array is similar than the first element",d);
return 0;
}
Disha
plz tell me whats the problem
Anonymous
Disha
__.whizz.__
i want to learn c programming
Anonymous
Ni
Could somebody answer the question:
Ni
ostream * old_tie = cin.tie(nullptr)
Seems it returns the cout.
Ni
Is it correct that the tie() returns the former tied ostream?
Ni
I thought it would return nullptr
Ni
The cppreference says the tie() "returns the tied stream, or a null pointer if there was no tied stream". I think it would returns nullptr since cin has no tied stream now
Anonymous
Count
Guys, I have a doubt. I have a variable "name" and is under string. cin>>name will only allow me to take just one name. I want it to take whatever I type. For example, like Jon Doe. Can someone help?
Count
I tried using getline and gets function but it didn't work
Ni
_dvd
Hi everyone
Quick question: is it possible to use std::copy_n with an input and output iterator belonging to the same fstream opened in both read and write mode?
I've tried to do such a thing with a stringstream to implement a sliding window over a text file and it worked, but the same doesn't hold using fstream
Anonymous
_dvd