Active Members MrGrj Posted November 21, 2014 Active Members Report Posted November 21, 2014 Bun...Trecand si eu acum nu mult timp prin asta, (pe vremea in care nu stiam sa fac diferenta intre un IDE si 3 litere random din alfabet) m-am gandit sa ofer un mic ajutor celor care intampina dificultati in rezolvarea aplicatiilor / problemelor in C sau C++. Ajutorul il ofer gratuit oricui are nevoie de indrumare, cu o singura conditie: - un gram de seriozitate + initiativa din partea doritorului.Nu accept PM-uri de genu':Am si eu n milioane de probleme. Fa-le. Pa si du-te-n *** .Vreau sa vad putin interes si determinare din partea voastra. Poate, cine stie..ajunge sa va placa 1 Quote
AndreeaLoredana Posted December 2, 2014 Report Posted December 2, 2014 S? se scrie un program C care sa determine dac? o propozitie este palindrom?. O propozitie este palindrom? daca citit? de la prima liter? pan? la ultima are aceeasi succesiune ca citit? de la ultima liter? pân? la prima. Nu conteaza dac? sunt litere mici sau mari.Exemplu: ele fac cafele Quote
Silviu Posted December 3, 2014 Report Posted December 3, 2014 S? se scrie un program C care sa determine dac? o propozitie este palindrom?. O propozitie este palindrom? daca citit? de la prima liter? pan? la ultima are aceeasi succesiune ca citit? de la ultima liter? pân? la prima. Nu conteaza dac? sunt litere mici sau mari.Exemplu: ele fac cafele#include <stdio.h>#include <string.h>int main() { char one[200] = "elefaccafele"; char two[200]; strcpy(two, one); strrev(two); if(strcmp(one, two) == 0) printf("The entered string %s is a palindrome.\n", one); else printf("The entered string %s is not a palindrome.\n", one); printf("The reverse of the string is %s.\n", two); return 0;}Sursa Quote
Active Members MrGrj Posted December 3, 2014 Author Active Members Report Posted December 3, 2014 O sa va rog sa imi dati PM, nu stau mereu sa verific thread-ul Solutia lui @Silviu este oricum cea mai usoara si cel mai usor de inteles. Quote
nedo Posted December 5, 2014 Report Posted December 5, 2014 Atunci cand MrGrj ese prea ocupat, puteti apela si la mine. Quote
Begedeu Posted January 24, 2015 Report Posted January 24, 2015 (edited) Salut , voiam sa trimit pm lui @MrGrj dar mi-am amintit de acest topic .Va rog frumos sa ma ajutati la aceasta problema , nu prea am inteles functiile .Thanks a lot.http://s14.postimg.org/ww7dxhi0x/functii.pngEdit : Am terminat , acum vreau doar sa imi spuneti daca e bine .#include <cstdlib>#include <iostream>#include <string>#include <conio.h>using namespace std;int askUser(int high, int low=1);string askText(string prompt);int triple (int number);string triple (string name);int main(){ string text; string name = askText("What`s your name: ?"); int number = askUser(5); cout <<"Thanks for entering " <<number<< "\n\n"; cout <<"Triple the number: " <<triple(number)<<"\n\n"; cout <<"Triple the name: " <<triple(name)<<"\n\n"; cin.ignore(cin.rdbuf()->in_avail() +1); getchar(); return 0;} string askText(string prompt) { string text; cout <<prompt; cin >> text; return text; }int askUser(int high, int low){ int num; do{ cout <<"Please enter a number" << " (" <<low<< "-" <<high<< "): "; ;cin>>num; } while (num > high || num < low); return num; } int triple(int number){ return (number * 3); } string triple(string name){ return (name + name + name); } Edited January 24, 2015 by Begedeu Quote
Active Members MrGrj Posted January 24, 2015 Author Active Members Report Posted January 24, 2015 #include <string>#include <iostream>using namespace std;int askNumber(string prompt = "Enter a number: ");int askNumber(int guess);int main() { int number = askNumber("Introduceti un nr:: "); cout << "Ai introdus: " << number << endl; int guess; cout << "Introduceti alt numar: "; cin >> guess; guess = askNumber(guess); cout << "Ai introdus: " << guess << endl;}int askNumber(string prompt) { int guess; cout << prompt; cin >> guess; return guess;}int askNumber(int guess) { int guess2 = guess; return guess2;}Nu stiu de ce ai scris asa mult in problema asta. Cred ca e suficient ce ai aici. Vad si inmultiri si adunari. Nu stau sa analizez ca n-am timp, da' nu pare tocmai in regula. Quote
Begedeu Posted January 24, 2015 Report Posted January 24, 2015 Codul tau nu mi-l compileaza pe dev , o sa imi iau si eu visul studio .Al meu returneaza asta , cred ca este in regula .Multumesc mult de ajutor. Quote