RusSimona

pg 159 ex 36

Jun 21st, 2019
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. #include<iostream>
  2. #include<string.h>
  3.  
  4. using namespace std;
  5.  
  6. int f(char a[51], int k)
  7. {
  8. int i;
  9. char rez[51];
  10. if(strlen(a)<k) cout<<"nu este posibil";
  11. else
  12. {
  13. for(i=0; i<k; i++)
  14. {
  15. cout<<a[i];
  16. }
  17. }
  18.  
  19. }
  20.  
  21. char s[51][51];
  22. int main ()
  23.  
  24. {
  25. int n,i;
  26. cin>>n;
  27.  
  28. for(i=1; i<=n; i++)
  29. {
  30. cin>>s[i];
  31. }
  32. for(i=1; i<=n; i++)
  33. {
  34. f(s[i],i);
  35. cout<<endl;
  36. }
  37.  
  38. }
Add Comment
Please, Sign In to add comment