Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
520 views
in Technique[技术] by (71.8m points)

c++ - I am getting error like [Error] cannot convert '__complex__ int' to 'int' in assignment

here is my code and I amgetting error cannot convert 'complex int' to 'int' in assignment

#include<iostream>
using namespace std;

int main() {
    // Write your code here
    int x;
    cin>>x;
    int res=0;
  
    for (int i=1;i<=5;i++){
   res = 3i+2;

    }
      cout <<res;
}
question from:https://stackoverflow.com/questions/66057833/i-am-getting-error-like-error-cannot-convert-complex-int-to-int-in-ass

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Your code is syntactically incorrect. I assume the correct code is this-->

#include<iostream>
using namespace std;

int main() {
// Write your code here
int x;
cin>>x;
int res=0;

for (int i=1;i<=5;i++){
     res = 3*i+2;
}
   cout <<res;
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...