CCCC
6 отговора
0 прегледа
CCCC
Това което виждате е игра на познай магическото число, но след един опит програмата свършва.Как да продължи цикъла?С return x; ли?
#include<stdio.h>
int main(void) {
int x;
printf("This is a game of guess the magic number \n");
printf("Enter a number:");
scanf("%d", &x);
if(x == 41)
printf("Correct");
if(x < 41) printf("The number is greater.Try again:");
if(x > 41) printf("The number is not greater.Try again:");
scanf("%d", &x);
???????????????????????????????????????
#include<stdio.h>
int main(void) {
int x;
printf("This is a game of guess the magic number \n");
printf("Enter a number:");
scanf("%d", &x);
if(x == 41)
printf("Correct");
if(x < 41) printf("The number is greater.Try again:");
if(x > 41) printf("The number is not greater.Try again:");
scanf("%d", &x);
???????????????????????????????????????
Re: CCCC
Da rechem taka:
#include<stdio.h>
int main(void) {
int x;
printf("This is a game of guess the magic number \n");
printf("Enter a number:");
scanf("%d", &x);
do{
if(x < 41) printf("The number is greater.Try again:");
if(x > 41) printf("The number is not greater.Try again:");
scanf("%d", &x);
}while(x != 41);
printf("Correct");
return 0;
}
Ne e zle da pocetesh malko poweche.
#include<stdio.h>
int main(void) {
int x;
printf("This is a game of guess the magic number \n");
printf("Enter a number:");
scanf("%d", &x);
do{
if(x < 41) printf("The number is greater.Try again:");
if(x > 41) printf("The number is not greater.Try again:");
scanf("%d", &x);
}while(x != 41);
printf("Correct");
return 0;
}
Ne e zle da pocetesh malko poweche.
Грешна програма
Познай какво ще стане, ако от първия път се въведе правилното число.
Истинският алгоритъм е този:
#include<stdio.h>
int main(void) {
int x;
printf("This is a game of guess the magic number \n");
do
{
scanf("Enter a number: %d", &x);
if(x < 41) printf("The number is greater.Try again:");
if(x > 41) printf("The number is not greater.Try again:");
}
while(x != 41);
printf("Correct\n");
return 0;
}
Не е зле да мислиш малко повече.
Si Vis Pacem, Para Bellum
Истинският алгоритъм е този:
#include<stdio.h>
int main(void) {
int x;
printf("This is a game of guess the magic number \n");
do
{
scanf("Enter a number: %d", &x);
if(x < 41) printf("The number is greater.Try again:");
if(x > 41) printf("The number is not greater.Try again:");
}
while(x != 41);
printf("Correct\n");
return 0;
}
Не е зле да мислиш малко повече.
Si Vis Pacem, Para Bellum
Re: Грешна програма
Tova e edna zadacha ot knigata C prakticheski samouchitel i tia e dadena mnogo predi da tsikalite while i do.Tai che niamashe kak da znaia kak da napravia programata.
Re: CCCC
ами пробваи с етикети
Label-i edin vid
polzvai dolniq algoritum algorituma
;)))))
Label-i edin vid
polzvai dolniq algoritum algorituma
;)))))