if (mistake) { printf("Invalid code.\n"); return -1; } }
printf("Fixed code: %s\n", input); for (i = 0; i < len; i++) if (i + 1 == b) b <<= 1; else info[info_pos++] = input; info[info_pos] = '\0'; printf("Informational string: %s\n", info); return 0; }
#include <stdlib.h>
char input[1024];
int len;
int find_mistake()
{
int i, mistake = 0;
for (i = 0; i < len; i ++)
if (input == '1')
mistake ^= i + 1;
return mistake;
}
int main()
{
int i, mistake = 0;
char info[1024];
int info_pos = 0;
int b = 1;
printf("Enter code: ");
scanf("%s", input);
len = strlen(input);
for (i = 0; i < len; i++)
if (input != '0' && input != '1')
{
printf("Invalid code.\n");
return -1;
}
mistake = find_mistake();
if (mistake)
{
input[mistake - 1] ^= '0' ^ '1';
mistake = find_mistake();
if (mistake)
{
printf("Invalid code.\n");
return -1;
}
}
printf("Fixed code: %s\n", input);
for (i = 0; i < len; i++)
if (i + 1 == b)
b <<= 1;
else
info[info_pos++] = input;
info[info_pos] = '\0';
printf("Informational string: %s\n", info);
return 0;
}
#include <math.h>
#include <glut.h>
void Draw ()
{
glClear (GL_COLOR_BUFFER_BIT);
glColor3f (0.7,0.7,1);
glTranslatef (200,200,0);
glBegin (GL_POINTS);
for (int i=0,R=30;i<5;i++,R+=10)
{
for (float x=-R;x<R;x+=0.01)
{
glVertex2f (R*sin(x),R*cos(x));
}
}
glEnd ();
glutSwapBuffers ();
}
void Init ()
{
glClearColor (1,1,1,1);
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
glOrtho (0,400, 0,400, 0,400);
glMatrixMode (GL_MODELVIEW);
}
int main (int argc,char** argv)
{
glutInit (&argc,argv);
glutInitDisplayMode (GLUT_DOUBLE|GLUT_RGB);
glutInitWindowSize (400,400);
glutInitWindowPosition (50,50);
glutCreateWindow ("Окружности");
glutDisplayFunc (Draw);
Init ();
glutMainLoop ();
return 0;
}