0% found this document useful (0 votes)
18 views

Using Namespace: STD Ifstream Ofstream

The document contains 3 C++ programs that analyze numeric input. The first program counts the unique digits in a number and outputs the count. The second program checks if a number contains only unique digits, outputting "da" for yes and "nu" for no. The third program checks if a number contains a given digit m exactly that number of times, outputting "da" or "nu" accordingly.

Uploaded by

Dorinel Panaite
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

Using Namespace: STD Ifstream Ofstream

The document contains 3 C++ programs that analyze numeric input. The first program counts the unique digits in a number and outputs the count. The second program checks if a number contains only unique digits, outputting "da" for yes and "nu" for no. The third program checks if a number contains a given digit m exactly that number of times, outputting "da" or "nu" accordingly.

Uploaded by

Dorinel Panaite
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

1.

#include <fstream>
using namespace std;
ifstream f("date.in");
ofstream g("date.out");
int cif[10];
int main ()
{
int n,i,c=0;
f>>n;
while (n) { cif[n%10]++; n/=10;}
for (i=0;i<=9;i++) if (cif[i]!=0) c++;
g<<c;
}

2.
#include <fstream>
using namespace std;
ifstream f("date.in");
ofstream g("date.out");
int cif[10];
int main ()
{
int n,i,OK=1;
f>>n;
while (n) { cif[n%10]++; n/=10;}
for (i=0;i<=9;i++) if (cif[i]>1) OK=0;
if (OK) g<<"da"; else g<<"nu";
}
3.
#include <fstream>
using namespace std;
ifstream f("date.in");
ofstream g("date.out");
int cif[10];
int main ()
{
int n,i,OK=0,m;
f>>n>>m;
while (n) { cif[n%10]++; n/=10;}
for (i=0;i<=9;i++) if (cif[i]==m) OK=1;
if (OK) g<<"da"; else g<<"nu";
}

You might also like