Jump to content
camera8811

Salut

Recommended Posts

Salut, Mi-a facut cineva un script in C# dar nu stiu cum sa il fac sa functioneze... am incercat cu, CodeBlocks ... dar nu am reusit. scriptul este acesta

for(int i = 0; i < length; i++)

{

unsigned char c = data;

if((i % 2) == 0) //pozitie para

{

c = c + 32 - (128 > c + 32 ? 32 : 64);

}

else //pozitie impara

{

c = c + 8 - (128 > c + 8 ? 32 : 64);

}

printf("%c", c);

}

Imi poate explica cineva cum il fac sa mearga? Multumesc

Link to comment
Share on other sites

  • Active Members

Ia-ti Visual Studio.

Si asta nu vad de ce ar fii C# si nu C.

Cod complet:



#include<stdio.h>
#include<string.h>

int main()
{
int length;
char data[100];

printf("length=");scanf("%d",&length);
for(int i = 0; i < length; i++)
{
unsigned char c = data[i];
if((i % 2) == 0) //pozitie para
c = c + 32 - (128 > c + 32 ? 32 : 64);

else //pozitie impara
c = c + 8 - (128 > c + 8 ? 32 : 64);

printf("%c", c);

return 0;
}

M-ai omorat cu atatea acolade. In momentul in care ai doar o instructiune in if/for/else...etc nu sunt necesare acoladele.

Ti l-am facut in C pentru ca asta nu e nicidecum C#.

Tutorial cum sa creezi un proiect in Visual Studio gasesti

.

PS: Asta nu e un script, e un program. Si mai mult, ai idee ce face programul asta ? Sau ce ar trebui sa faca ?

  • Downvote 1
Link to comment
Share on other sites

Ia-ti Visual Studio.

Si asta nu vad de ce ar fii C# si nu C.

Cod complet:



#include<stdio.h>
#include<string.h>

int main()
{
int length;
char data[100];

printf("length=");scanf("%d",&length);
for(int i = 0; i < length; i++)
{
unsigned char c = data[i];
if((i % 2) == 0) //pozitie para
c = c + 32 - (128 > c + 32 ? 32 : 64);

else //pozitie impara
c = c + 8 - (128 > c + 8 ? 32 : 64);

printf("%c", c);

return 0;
}

M-ai omorat cu atatea acolade. In momentul in care ai doar o instructiune in if/for/else...etc nu sunt necesare acoladele.

Ti l-am facut in C pentru ca asta nu e nicidecum C#.

Tutorial cum sa creezi un proiect in Visual Studio gasesti

.

PS: Asta nu e un script, e un program. Si mai mult, ai idee ce face programul asta ? Sau ce ar trebui sa faca ?

Da, Ar trebuii sa imi decripteze niste parole criptate. Si multumesc frumos bro:D

Link to comment
Share on other sites

1>------ Build started: Project: noname, Configuration: Debug Win32 ------

1> main.c

1>c:\users\maduu\documents\visual studio 2010\projects\noname\noname\main.c(9): warning C4996: 'scanf': This function or variable may be unsafe. Consider using scanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.

1> c:\program files\microsoft visual studio 10.0\vc\include\stdio.h(304) : see declaration of 'scanf'

1>c:\users\maduu\documents\visual studio 2010\projects\noname\noname\main.c(10): error C2143: syntax error : missing ';' before 'type'

1>c:\users\maduu\documents\visual studio 2010\projects\noname\noname\main.c(10): error C2143: syntax error : missing ';' before 'type'

1>c:\users\maduu\documents\visual studio 2010\projects\noname\noname\main.c(10): error C2143: syntax error : missing ')' before 'type'

1>c:\users\maduu\documents\visual studio 2010\projects\noname\noname\main.c(10): error C2143: syntax error : missing ';' before 'type'

1>c:\users\maduu\documents\visual studio 2010\projects\noname\noname\main.c(10): error C2065: 'i' : undeclared identifier

1>c:\users\maduu\documents\visual studio 2010\projects\noname\noname\main.c(10): warning C4552: '<' : operator has no effect; expected operator with side-effect

1>c:\users\maduu\documents\visual studio 2010\projects\noname\noname\main.c(10): error C2065: 'i' : undeclared identifier

1>c:\users\maduu\documents\visual studio 2010\projects\noname\noname\main.c(10): error C2059: syntax error : ')'

1>c:\users\maduu\documents\visual studio 2010\projects\noname\noname\main.c(11): error C2143: syntax error : missing ';' before '{'

1>c:\users\maduu\documents\visual studio 2010\projects\noname\noname\main.c(12): error C2065: 'i' : undeclared identifier

1>c:\users\maduu\documents\visual studio 2010\projects\noname\noname\main.c(13): error C2065: 'i' : undeclared identifier

1>c:\users\maduu\documents\visual studio 2010\projects\noname\noname\main.c(23): fatal error C1075: end of file found before the left brace '{' at 'c:\users\maduu\documents\visual studio 2010\projects\noname\noname\main.c(5)' was matched

========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Dupa ce am pus exact ce mi-ai pus tu acolo imi da aceasta eroare..

Gresesc eu undeva? Te rog ajuta-ma... Multumesc

Edited by camera8811
Link to comment
Share on other sites

  • Active Members

Poftim codul scris si testat, insa nu te astepta sa iti decripteze/afiseze ceea ce vrei tu fara sa mai umbli prin el pentru ca vectorul ala data e gol, iar c nu primeste decat 1,2,3 .... pana la ce valoare il dai pe length.

Invata putina programare pentru ca e basic programul asta, si apoi apuca-te de decriptat ceva.

E doar un sfat, insa nu stau sa iti dau mura-n gura acum.


#include<stdio.h>
#include<string.h>

int main()
{
int length;
char data[100];
unsigned char c;
printf("length=");scanf("%d",&length);

for(int i = 0; i < length; i++)
{
c=data[i];
if((i % 2) == 0) //pozitie para
c = c + 32 - (128 > c + 32 ? 32 : 64);

else //pozitie impara
c = c + 8 - (128 > c + 8 ? 32 : 64);
}

printf("%c", c);

return 0;
}

//se poate inchide, s-a rezolvat

Edited by MrGrj
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...