User
Pass
2FA
 
 

Putin ajutor la info.

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Freakz Forum Index -> Trash Bin -> Trash -> Homework zone
Author Message1040
SharinganLeX

[Account disabled]



Status: Offline
(since 23-01-2014 15:47)
Joined: 18 Nov 2011
Posts: 432, Topics: 79
Location: Bucuresti

Reputation: 25.9
Votes: 8

Post Posted: 28-02-2013, 21:02:41 | Translate post to: ... (Click for more languages)

Cine ma poate ajuta cu o problema de informatica? (clasa a 10a)
Se citesc de la tastatura un nr. nat "n" (maxim 9 cifre) scrieti program c++ care afiseaza nr. format din aceleasi cifre ale lui n modificate astfel, cifrele pare cresc cu o unitate, iar cele impare scad cu o unitate.

Asa am incercat eu dar nu cred ca e bine:

#include <iostream.h>
void main()
{unsigned long n,m;
cout<<"n="; cin>>n; cin>>m;
n=m
while(m%2=0) m++
while(m%3=0) m--


Multumesc anticipat.

0 0
  
Back to top
View user's profile Send private message
Alexander0810

[VIGILO CONFIDO]



Status: Offline
(since 08-03-2024 13:58)
Joined: 13 Mar 2010
Posts: 12665, Topics: 267
Location: Romania

Reputation: 2269
Votes: 151

 
Post Posted: 28-02-2013, 21:26:03 | Translate post to: ... (Click for more languages)

Ti-am raspuns in celalalt, l-am facut cat mai de "clasa a-10-a" am putut.
0 0
  
Back to top
View user's profile Send private message
mojii

[Mentally Stable]



Status: Offline
(since 13-05-2015 11:58)
Joined: 16 Jan 2011
Posts: 85, Topics: 13
Location: Romania

Reputation: 122.1
Votes: 2

 
Post Posted: 24-03-2013, 20:53:12 | Translate post to: ... (Click for more languages)

#include "stdafx.h"
#include <iostream>
using namespace std;



void main()
{

long int nr = 0,
cifra = 0,
new_nr = 0,
cifre_first = 0,
cifre_last = 0;



cout << "Introdu nr: "; cin >> nr;
if (nr < 0)
cout << "Numarul nu este natural!" << endl;
else
{
while (nr != 0)
{
cifra = nr % 10;
if (cifra % 2 == 0)
new_nr = new_nr * 10 + cifra + 1;
else new_nr = new_nr * 10 + cifra - 1;
cifre_first ++;
nr = nr / 10;
}

nr = 0;

while(new_nr != 0)
{
cifra = new_nr % 10;
nr = nr * 10 + cifra;
cifre_last++;
new_nr = new_nr / 10;
}

if (cifre_first != cifre_last)
nr *= 10;

cout << "Noul numar este: " << nr << endl;

}

system("PAUSE");
}

0 0
  
Back to top
View user's profile Send private message

  Topic locked


Topic is closed, you cannot post any messages in it anymore




 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Freakz Forum Index -> Trash Bin -> Trash -> Homework zone  


The time now is 27-04-2024, 18:35:51
Copyright info

Based on phpBB ro/com
B

 
 
 







I forgot my password


This message appears only once, so
like us now until it's too late ! :D
x