Advertisement
SumitParakh

Replace Question Mark

Sep 8th, 2012
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.46 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include<iostream>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int arr[4][3]={
  8. {8,'?',21},
  9. {35,'?',12},
  10. {32,'?',31},
  11. {4,'?',28}
  12. };
  13.  
  14. int l,sum=0;
  15. for(int i=0;i < 4;i++)
  16. {
  17.  
  18. for(int j=0;j < 3;j++)
  19. {
  20. if(j>0)
  21. {
  22. l=arr[i][0];
  23. if(j==2 && arr[i][j-1]==(int)'?')
  24. {
  25. int val=arr[i][j];
  26. while(val!=0)
  27. {
  28. sum=sum+val%10;
  29. val/=10;
  30. }
  31. arr[i][j-1]=l-sum; // m
  32. cout<<arr[i][j-2]<<"\t"<<arr[i][j-1]<<"\t"<<arr[i][j]<<endl;
  33. sum=0;
  34. }
  35.  
  36. }
  37. }
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement