Advertisement
LegoDrifter

Untitled

Jan 21st, 2021
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <ctype.h>
  5. void wtf()
  6. {
  7. FILE *fpointer;
  8. fpointer = fopen("input.txt","w");
  9. fprintf(fpointer,"Jas ucham Strukturno Programiranje.\nKoga se polaga vtoriot kolokvium?\nNe znam, seushte ne e objaveno na sajtot.");
  10. fclose(fpointer);
  11. }
  12. int main()
  13. {
  14. //wtf();
  15. FILE *input;
  16. if((input = fopen("input.txt","r"))==NULL)
  17. {
  18. printf("Datotekata ne mozhe da se otvori.");
  19. return -1;
  20. }
  21. FILE *output;
  22. output = fopen("output.txt","w");
  23. int n,a[100][100],suma=0;
  24. fscanf(input,"%d",&n);
  25. for(int i=0;i<n;i++)
  26. {
  27. for(int j=0;j<n;j++)
  28. {
  29. fscanf(input,"%d\n",&a[i][j]);
  30. if(i==j)
  31. {
  32. suma+=a[i][j];
  33. }
  34. }
  35. }
  36. for(int i=0;i<n;i++)
  37. {
  38. for(int j=0;j<n;j++)
  39. {
  40. if(i<j)
  41. {
  42. a[i][j]=suma;
  43. }
  44. }
  45. }
  46. for(int i=0;i<n;i++)
  47. {
  48. for(int j=0;j<n;j++)
  49. {
  50. if(i<j)
  51. {
  52. fprintf(output,"%d ",suma);
  53. }
  54. else
  55. fprintf(output," ");
  56. }
  57. fprintf(output,"\n");
  58. }
  59. fclose(input);
  60. fclose(output);
  61. return 0;
  62. }
  63.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement