Advertisement
Guest User

Untitled

a guest
Mar 19th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 KB | None | 0 0
  1. // ConsoleApplication27.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <fcntl.h>
  6. #include <io.h>
  7. #include <iostream>
  8. #include <fstream>
  9. #include <iomanip>
  10. #include <string>
  11.  
  12. const char duom[] = "Duomenys.txt";
  13. const char rez[] = "Rezultatai.txt";
  14. const int cMax = 100;
  15. /**/
  16. int Kiek(char sim);
  17. /**/
  18. using namespace std;
  19.  
  20. int main(){
  21. char S[cMax],D[cMax],F[cMax];
  22. int A[cMax],B[cMax],C[cMax];
  23. int n = 0, m = 0, g = 0;
  24.  
  25. for (char big = toupper('a'); big <= toupper('z'); big++) {
  26. F[g] = big; C[g] = Kiek(big);
  27. g++;
  28. }
  29. for (char sk = '0'; sk <= '9'; sk++) {
  30. S[n] = sk; A[n] = Kiek(sk);
  31. n++;
  32. }
  33. for (char sim = 'a'; sim <= 'z'; sim++) {
  34. D[m] = sim; B[m] = Kiek(sim);
  35. m++;
  36. }
  37. D[m] = 'ą'; D[m] = Kiek('ą'); m++;
  38. D[m] = 'č'; D[m] = Kiek('č'); m++;
  39. D[m] = 'ę'; D[m] = Kiek('ę'); m++;
  40. D[m] = 'ė'; D[m] = Kiek('ė'); m++;
  41. D[m] = 'į'; D[m] = Kiek('į'); m++;
  42. D[m] = 'š'; D[m] = Kiek('š'); m++;
  43. D[m] = 'ų'; D[m] = Kiek('ų'); m++;
  44. D[m] = 'ū'; D[m] = Kiek('ū'); m++;
  45. D[m] = 'ž'; D[m] = Kiek('ž'); m++;
  46. D[m] = ' '; D[m] = Kiek(' '); m++;
  47.  
  48. F[g] = 'ą'; F[g] = Kiek('ą'); g++;
  49. F[g] = 'č'; F[g] = Kiek('č'); g++;
  50. F[g] = 'ę'; F[g] = Kiek('ę'); g++;
  51. F[g] = 'ė'; F[g] = Kiek('ė'); g++;
  52. F[g] = 'į'; F[g] = Kiek('į'); g++;
  53. F[g] = 'š'; F[g] = Kiek('š'); g++;
  54. F[g] = 'ų'; F[g] = Kiek('ų'); g++;
  55. F[g] = 'ū'; F[g] = Kiek('ū'); g++;
  56. F[g] = 'ž'; F[g] = Kiek('ž'); g++;
  57. F[g] = ' '; F[g] = Kiek(' '); g++;
  58.  
  59. ofstream fr(rez);
  60. fr << "Skaičiai" << endl;
  61. for (int q = 0; q < g; q++) {
  62. fr << F[q] << " " << setw(2) << C[q] << " ";
  63. fr << endl;
  64. }
  65. fr << "Mažosios raidės:" << endl;
  66. for (int i = 0; i < n; i++) {
  67. fr << S[i] << " " << setw(2) << A[i] << " ";
  68. fr << endl;
  69. }
  70. fr << endl;
  71. fr << "Didžiosios raidės:" << endl;
  72. for (int j = 0; j < m; j++) {
  73. fr << D[j] << " " << setw(2) << B[j] << " ";
  74. fr << endl;
  75. }
  76. fr.close();
  77.  
  78. return 0;
  79. }
  80.  
  81. int Kiek(char sim) {
  82. char s;
  83. int k = 0;
  84. ifstream fd(duom);
  85. while (!fd.eof()) {
  86. fd.get(s);
  87. if (!fd.eof() && (s == sim)) k++;
  88. }
  89. fd.close();
  90. return k;
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement