Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- NUMERO PIÙ GRANDE TRA DUE NUMERI
- #include <iostream>
- using namespace std;
- int main() {
- int n1,n2;
- cout << "Inserisci un primo numero:\n";
- cin >> n1;
- cout << "Inserisci un secondo numero:\n";
- cin >> n2;
- if (n1>n2)
- cout<<"il numero più grande tra questi due è: "<<n1;
- if (n2>n1)
- cout<<"il numero più grande tra questi due è: "<<n2;
- if (n1==n2)
- cout<<"il numero più grande tra questi due è: "<<n1;
- return 0;
- }
- PREZZO CON IVA, SCONTATO SOPRA I 100 EURO
- #include <iostream>
- using namespace std;
- int main() {
- float prezzo;
- cout << "Dammi il prezzo senza IVA: \n";
- cin >> prezzo;
- if (prezzo>100)
- {cout<<"Essendo il prezzo maggiore di 100 euro meriti uno sconto del 35%: \n";
- prezzo=prezzo*65/100;
- cout<<prezzo<<"\n";
- cout<<"Pur essendo scontato, a questo prezzo va aggiunta l'IVA: \n";
- prezzo=prezzo*120/100;}
- else
- { cout<<"A questo prezzo va aggiunta l'IVA: \n";
- prezzo=prezzo*120/100;}
- cout << prezzo;
- return 0;
- }
- ORDINAZIONE CRESCENTE DI TRE NUMERI
- #include <iostream>
- using namespace std;
- int main() {
- int a,b,c;
- cout << "Inserisci tre numeri diversi e te li ordinerò!\n";
- cout << "Primo numero:\n";
- cin>>a;
- cout << "Secondo numero:\n";
- cin>>b;
- cout << "Terzo numero:\n";
- cin>>c;
- if (a<=b and a<=c)
- {cout<<a<<"-";
- if (b<=c)
- {cout<<b<<"-";
- cout<<c;}
- else
- {cout<<c<<"-";
- cout<<b;}
- }
- else
- {if (b<=a and b<=c)
- {cout<<b<<"-";
- if (a<=c)
- {cout<<a<<"-";
- cout<<c;}
- else
- {cout<<c<<"-";
- cout<<a;}
- }
- else
- {if (c<=b and c<=a)
- {cout<<c<<"-";
- if (b<=a)
- {cout<<b<<"-";
- cout<<a;}
- else
- {cout<<a<<"-";
- cout<<b;}
- }}}
- return 0;
- }
- ORDINAZIONE CRESCENTE DI TRE NUMERI IMMESSI OBBLIGATORIAMENTE UGUALI
- #include <iostream>
- using namespace std;
- int main() {
- int a,b,c,max,med,min;
- cout << "Inserisci tre numeri diversi e te li ordinerò!\n";
- cout << "Primo numero:\n";
- cin>>a;
- do {cout << "Secondo numero:\n";
- cin>>b;}
- while (a==b);
- /* o si può anche fare:
- cout << "Secondo numero:\n";
- cin>>b;
- while (a==b)
- {cout << "Il secondo numero deve essere diverso:\n";<--!con la possibilità di
- cambiare la scritta che nel primo caso rimaneva sempre la stessa!
- cin>>b; }*/
- do {cout << "Terzo numero:\n";
- cin>>c;}
- while (b==c or a==c);
- if (a>b)
- max=a;
- else
- max=b;
- if (c>max)
- max=c;
- if (a<b)
- min=a;
- else
- min=b;
- if (c<min)
- min=c;
- if (a>min and a<max)
- med=a;
- else if (b>min and b<max)
- med=b;
- else
- med=c;
- cout<<min<<"-"<<med<<"-"<<max;
- return 0;
- }
- CONTO ALLA ROVESCIA CON FUNZIONE FOR
- #include <iostream>
- using namespace std;
- int main() {
- for (int i=100;i>0;i--)
- cout<<i<<endl;
- cout<<"BOOM!!!";
- return 0;
- }
- TABELLINE CON FUNZIONE FOR
- #include <iostream>
- using namespace std;
- int main() {
- int a,b,h,w;
- w=-1;
- cout<<"Dimmi un numero e ti dirò la tabellina:";
- cin>>a;
- for (int i=1;i<11;i++)
- cout<<a<<" * "<<i<<" = "<<a*i<<"\n";
- return 0;
- }
- DISEGNA RETTANGOLO, PARALLELOGRAMMA, TRIANGOLO CON FUNZIONE FOR
- (Il triangolo non funziona perfettamente, è stato fatto da me
- quindi potrebbe essere diverso da quello spiegato dal prof)
- #include <iostream>
- using namespace std;
- int main()
- {
- int b,h,w,q;
- cout<<"Dimmi la misura della base e dell'altezza di un rettangolo e te lo disegnerò:\n"<<"Base:";
- cin>>b;
- cout<<"Altezza:";
- cin>>h;
- cout<<"\n";
- for (int i=0; i<h;i++)
- { /*for (int i=0; i<b;i++)
- cout<<"r";*/
- for (int i=w; i<(b+h)-1;i++)
- cout<<" ";
- for (int i=0; i<b;i++)
- cout<<"○ ";
- cout<<"\n";}
- cout<<"\n";
- w=-1;
- for (int i=0; i<h;i++)
- { /*for (int i=0; i<b;i++)
- cout<<" ";*/
- w++;
- for (int i=w; i<(b+h)-1;i++)
- cout<<" ";
- q--;
- for (int i=0; i<b;i++)
- cout<<"○ ";
- cout<<"\n";}
- cout<<"\n";
- w=-1;
- q=b;
- for (int i=0; i<h;i++)
- { /*for (int i=0; i<b;i++)
- cout<<" ";*/
- w++;
- for (int i=w; i<(b+h)-1;i++)
- cout<<" ";
- q--;
- for (int i=q; i<b;i++)
- cout<<"o ";
- cout<<"\n";}
- cout<<"\n"<<"Federico Bartolini SRL";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment