Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ///SII 4.
- #include <iostream>
- #include <cstring>
- using namespace std;
- int main()
- {
- char s[20],x[20];
- cin.getline(s,20);
- if(strlen(s)%2==0){
- strcpy(x,s);
- }
- else{
- strcpy(x,s);
- /// cout<<x+strlen(x)/2<<endl;
- /// cout<<x+strlen(x)/2+1<<endl;
- strcpy(x+strlen(x)/2,x+strlen(x)/2+1);
- }
- cout<<x;
- return 0;
- }
- SII 5.
- #include <iostream>
- #include <cmath>
- using namespace std;
- int main()
- {
- int n,a[51][51]={};
- cin>>n;
- for(int i=1;i<=n;i++){
- for(int j=1;j<=n;j++){
- if(i+j==n || i+j==n+1 || i+j==n+2) a[i][j]=1; ///pseudodiagonale sec
- /// if(i==j || i==j+1 || i==j-1) a[i][j]=1; ///pseudodiagonale princ
- else a[i][j]=2;
- cout<<a[i][j]<<" ";
- /// cout<<i<<j<<" ";
- }
- cout<<endl;
- }
- return 0;
- }
- SIII 3.
- #include <iostream>
- #include <cmath>
- using namespace std;
- void divizori(int n,int &x,int &y,int &z)
- {
- x=0; y=0; z=0;
- int i,j,k;
- for(i=1;i<=n/2;i++){
- for(j=i+1;j<=n/2;j++){
- for(k=j+1;k<=n/2;k++){
- if(i+j+k==n && n%i==0 && n%j==0 && n%k==0){
- x=i; y=j; z=k;
- break;
- }
- }
- }
- }
- }
- int main()
- {
- int x,y,z,n;
- cin>>n;
- divizori(n,x,y,z);
- cout<<x<<" "<<y<<" "<<z;
- return 0;
- }
- SIII 4.
- #include <iostream>
- #include <fstream>
- using namespace std;
- ifstream fin("bac.txt");
- int a[100]={};
- int main()
- {
- int nr,subnr;
- while(fin>>nr){
- ///preiau toate subnumerele lui nr
- while(nr>=10){
- subnr=nr%100;
- a[subnr]++;
- nr=nr/10;
- }
- }
- for(int x=10;x<=99;x++){
- if(a[x]==1){
- cout<<x<<" ";
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement