Advertisement
rotti321

cuvinte9

Jan 16th, 2022
37
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <cstring>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. char a[101],cuv[101][101],*p,separator[]=" ";
  8. cin.get(a,101);
  9. p=a;
  10. p=strtok(p,separator);
  11. int nr=0;
  12. while(p!=NULL)
  13. {
  14. nr++;
  15. strcpy(cuv[nr],p);
  16. p=strtok(NULL,separator);
  17. }
  18. char pc='0';
  19. int poz=0;
  20. for(int i=1;i<=nr;++i){ ///iau toate cuvintele si verific
  21. ///daca este numar si are prima cifra max
  22. if((cuv[i][0]>='0' && cuv[i][0]<='9')&&cuv[i][0]>pc)
  23. pc=cuv[i][0],poz=i;
  24. }
  25. if(poz!=0)
  26. cout<<cuv[poz]<<'\n';
  27. else
  28. cout<<"nu exista\n";
  29. return 0;
  30. }
Advertisement
RAW Paste Data Copied
Advertisement