Advertisement
Guest User

Untitled

a guest
Nov 27th, 2014
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6.  
  7. int main(){
  8. int n=0;
  9. int x=0;
  10. int y=0;
  11. int suma[10000]={0};
  12. int tab[10000]={0};
  13. int tab2[10000]={0};
  14.  
  15. cin >> n;
  16.  
  17. for (int i=0;i<n;i++){
  18. cin >> x;
  19.  
  20. for(int j=(x-1);j>=0;j--){
  21. cin >> tab[j];
  22. }
  23.  
  24. cin >> y;
  25.  
  26. for(int k=(y-1);k>=0;k--){
  27. cin >> tab2[k];
  28. }
  29.  
  30. if(x>y){
  31. for(int m=0;m<x;m++){
  32. suma[m] += tab[m]+tab2[m];
  33. if(suma[m]>=2){
  34. suma[m] -= 2;
  35. suma[m+1] += 1;
  36. cout << suma[m] << " ";
  37. }
  38. }
  39. }
  40. else{
  41. for(int m=0;m<y;m++){
  42. suma[m] += tab[m]+tab2[m];
  43. if(suma[m]>=2){
  44. suma[m] -= 2;
  45. suma[m+1] += 1;
  46. cout << suma[m] << " ";
  47. }
  48. }
  49. }
  50.  
  51. cout << endl;
  52. }
  53.  
  54. return 0;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement