I have a task from my teacher,like : x^2 + y^3 = z
x filled only with odd y filled only with even
#include <stdio.h>
#include <string>
#include <iostream>
using namespace std;
int x,y,z;
int main(){
for (x=1;x<=20;x++){
if ((x%2==1)&&(y%2==0)){
for (y=1;y<=20;y++){
if ((x%2==1)&&(y%2==0)){
z = (x*x) + (y*y*y);
cout << "x^2 + y^3 =" <<z <<"\n";
}
}
}
}
}
I try to make my own code like above ,but the only one loop is Y , x stand still with 1.
I want to make x to be looping too. What should i do?
PS. Im sorry with my bad english :D
Aucun commentaire:
Enregistrer un commentaire