Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1 d
- II 1 a)
- 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
- x x 3 4 x 6 x 8 9 x x x x x 15
- 3 4 6 8 9 15
- a%b==a ,a<b
- 2 b) 10 7 7, 20 5 5
- 2 c)
- #include <iostream>
- using namespace std;
- int main() {
- int n,x,y,ok;
- cin>>n>>x>>y;
- ok=0;
- for(int i=1;i<=n;i++){
- if((i%x==0 && i%y!=0) ||
- (i%x!=0 && i%y==0)){
- cout<<i<<" ";
- ok=1;
- }
- }
- if(ok==0) cout<<0;
- return 0;
- }
- 2 d)
- citește n,x,y
- (numere naturale nenule, x≤n, y≤n)
- ok<-0
- i<-1
- ┌cat timp i<=n execută
- │┌dacă (i%x=0 și i%y≠0) sau
- ││ (i%x≠0 și i%y=0) atunci
- ││ scrie i, ' '
- ││ ok<-1
- || i<-i+1
- │└■
- └■
- ┌dacă ok=0 atunci scrie 0
- └■
- III
- 1.
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- int n;
- cin>>n;
- for(int i=n;i>=1;i--){
- cout << i*i*i; cout << " ";
- }
- return 0;
- }
- 3.
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- int n,a[100]={},b[100]={},m,x,z,u,sol=0;
- cin>>n>>m;
- for(int i=1;i<=n;i++){
- cin>>x;
- u=x%10;
- z=x%100/10;
- if(u<z){
- x=u*10+z;
- }
- else{
- x=z*10+u;
- }
- a[x]++;//crestem aparitia lui x in primul sir
- }
- for(int i=1;i<=m;i++){
- cin>>x;
- u=x%10;
- z=x%100/10;
- if(u<z){
- x=u*10+z;
- }
- else{
- x=z*10+u;
- }
- b[x]++;// crestem fregventa de aparitie a lui x in al doilea sir
- }
- for(int x=0;x<=99;x++){
- sol=sol+b[x]*a[x];
- }
- cout<<sol;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement