camera8811 Posted March 4, 2014 Report Share Posted March 4, 2014 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 acestafor(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 Quote Link to comment Share on other sites More sharing options...
Active Members MrGrj Posted March 4, 2014 Active Members Report Share Posted March 4, 2014 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 ? 1 Quote Link to comment Share on other sites More sharing options...
camera8811 Posted March 4, 2014 Author Report Share Posted March 4, 2014 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 Quote Link to comment Share on other sites More sharing options...
camera8811 Posted March 4, 2014 Author Report Share Posted March 4, 2014 (edited) 1>------ Build started: Project: noname, Configuration: Debug Win32 ------1> main.c1>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 identifier1>c:\users\maduu\documents\visual studio 2010\projects\noname\noname\main.c(10): warning C4552: '<' : operator has no effect; expected operator with side-effect1>c:\users\maduu\documents\visual studio 2010\projects\noname\noname\main.c(10): error C2065: 'i' : undeclared identifier1>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 identifier1>c:\users\maduu\documents\visual studio 2010\projects\noname\noname\main.c(13): error C2065: 'i' : undeclared identifier1>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 March 4, 2014 by camera8811 Quote Link to comment Share on other sites More sharing options...
Active Members MrGrj Posted March 4, 2014 Active Members Report Share Posted March 4, 2014 (edited) 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 March 4, 2014 by MrGrj Quote Link to comment Share on other sites More sharing options...