LegendKiller Posted February 11, 2010 Report Posted February 11, 2010 Am pt scoala , o problema , care suna in felul urmator : Se citesc patru numere intregi de la tastatura : a,b,c,d . Determinati care dintre produsele a*b si c*d este mai mare .Momentan eu am facut pana aici .#include <iostream>using namespace std;int main(){ long int a,b,c,d,max; cout<<"a="; cin>>a; cout<<"b="; cin>>b; cout<<"c="; cin>>c; cout<<"d="; cin>>d; max=0; if((a*>(c*d)) {cout<<"a*b este mai mare decat c*d"; else cout<<"c*d este mai mare decat a*b"; } return 0;}Imi da eroare si nu stiu de ce . Programul a fost facut in CodeBlocks. Quote
Nytro Posted February 11, 2010 Report Posted February 11, 2010 if((a*>(c*d)) cout<<"a*b este mai mare decat c*d";else cout<<"c*d este mai mare decat a*b"; Quote
cmiN Posted February 11, 2010 Report Posted February 11, 2010 Ai inclus else-ul in blocul de instructiuni al if-ului, fiecare are propriul bloc cuprins in cate o pereche de paranteze.#include <iostream>using namespace std;int main(){ unsigned long a, b, c, d; cout << "a="; cin >> a; cout << "b="; cin >> b; cout << "c="; cin >> c; cout << "d="; cin >> d; if ((a * > (c * d)) { cout << "a*b=" << a * b << " mai mare decat c*d=" << c * d; } else { cout << "c*d=" << c * d << " mai mare decat a*b=" << a * b; } system("pause >NUL"); return 0;} Quote
SENEQ_o Posted February 11, 2010 Report Posted February 11, 2010 #include <iostream.h>int a,b,c,d;int main(){ cin >>a>>b>>c>>d; if(a*b > c*d) cout << "a*b mai mare decat c*d"; else cout << "c*d mai mare decat a*b";}return 0;Folosesti Mingv studios in loc de CodeBlocks. e mult mai simplu... Quote