test52.cvc 653 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // 3.b: Scan vector / maxtrix
  2. extern int scanInt();
  3. extern float scanFloat();
  4. extern void printInt(int c);
  5. extern void printFloat(float c);
  6. void scan_vector(float [m] a)
  7. {
  8. for (int i = 0, m) {
  9. a[i] = scanFloat();
  10. }
  11. }
  12. void scan_matrix(float [m,n] a)
  13. {
  14. for (int i = 0, m) {
  15. for (int j = 0, n) {
  16. a[i,j] = scanFloat();
  17. }
  18. }
  19. }
  20. export int main()
  21. {
  22. int m = 3;
  23. int n = 3;
  24. void do_vector()
  25. {
  26. float [m] v;
  27. scan_vector(v);
  28. }
  29. void do_matrix()
  30. {
  31. float [m,n] M;
  32. scan_matrix(M);
  33. }
  34. if (n == 1 && m >= 1) {
  35. do_vector();
  36. }
  37. else if (n > 1 && m >= 1) {
  38. do_matrix();
  39. }
  40. return 0;
  41. }