Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sesiunea iunie-iulie, 4 iulie 2019 (Incercari)
- Subiect 3
- 1. #include<iostream>
- using namespace std;
- void impare (int n, int& r)
- {
- int p=1;
- r=0;
- while(n!=0)
- {
- r=r+n%10*p;
- p=p*10;
- if(n%10%2!=0)
- {
- r=r+(n%10-1)*p;
- }
- n=n/10;
- }
- }
- int main()
- {
- int n, r;
- cin>>n;
- impare(n, r);
- cout<<r;
- return 0;
- }
- 2. #include<iostream>
- using namespace std;
- int a[1001][1001];
- int main()
- {
- int n, m, i, j, k, l;
- cin>>m>>n;
- for(i=1; i<=m; i++)
- {
- for(j=1; j<=n; j++)
- {
- cin>>a[i][j];
- }
- }
- cout<<'\n';
- for(i=1; i<=m; i++)
- {
- for(j=1; j<=n/2; j++)
- {
- cout<<a[i][j]<<" ";
- }
- cout<<'\n';
- }
- cout<<'\n';
- for(k=1; k<=m; k++)
- {
- for(l=n; l>=n/2+2; l--)
- {
- cout<<a[k][l]<<" ";
- }
- cout<<'\n';
- }
- cout<<'\n';
- if(a[i][j]==a[k][l])
- {
- cout<<"DA";
- }
- else
- {
- cout<<"NU";
- }
- return 0;
- }
- 3. #include<iostream>
- #include<fstream>
- using namespace std;
- ifstream fin("bac.in");
- int ap[1001];
- int main()
- {
- int i, x, x_ant;
- fin>>x_ant;
- while(fin>>x)
- {
- if(x_ant>x)
- {
- ap[x_ant]++;
- x_ant=x;
- }
- }
- for(i=1; i<=1001; i++)
- {
- if(ap[i]!=0)
- {
- cout<<i<<" ";
- ap[i]--;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement