تازه های کامپیوتر و برنامه نویسی

آموزش کامپیوتر , برنامه نویسی , نرم افزار

تازه های کامپیوتر و برنامه نویسی

آموزش کامپیوتر , برنامه نویسی , نرم افزار

سورس کد یافتن کلمه ای دلخواه در متن به زبان c

برنامه ی زیر می تواند برای شما کلمه ای را که در متنی انتخاب شده وجود دارد پیدا کند ،بدین صورت که شماره ی اولین کاراکتر کلمه ی درخواستی را برایتان بر می گرداند.

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


void main ()
{
    char matn[2024]= "\tFlower was primarily intended to arouse positive emotions in player,\n\
    \trather than to be a challenging and fun game. This focus was sparked \n\
    \tby Chen, who felt that the primary purpose of entertainment products \n\
    \tgames was the feelings that they evoked in the audience, and that\n\
    \temotional range of most games was very limited. The team viewed\n \
    \ttheir efforts as creating a work of art, removing gameplay elements\n \
    \tmechanics that were not provoking the desired response in the players.\n\
    \tThe music, composed by Vincent Diamante, dynamically responds to the\n\
    \tplayer's actions and corresponds with the emotional cues in the game. \t\n" ;

     char kalame[80];
    char *ptrBekalame ;
    int n;

    printf("%s",matn);
    printf("dar matn balaa ,che kalame raa pieda konad:");
    scanf ("%s",kalame);
    ptrBekalame =strstr(matn,kalame);
    if (ptrBekalame==NULL){
        printf ("dar matn pieda nashod");
    } else {
            n=(int)(ptrBekalame-matn);
            printf ("kalame %s character %d ast",kalame,n);
    getch();
}
}

یافتن یک معما با برنامه نویسی به زبان c

صورت مسئله بدین صورت است که ما 5 معادله و 5 مجهول داریم و می خواهیم این 5 مجهول را با استفاده از برنامه نویسی و بدون نوشتن روی کاغذ و انجام محاسبات پیچیده وطاقت فرسا بدست آوریم؛ این 5 معادله بدین صورت هستند که :

(1) عدد اول از دو برابر عدد دوم یک واحد کمتر است.

(2) حاصل جمع عدد دوم با عدد سوم 10است .

(3) عدد چهارم یک واحد بیشتر از عدد دوم است.

(4) حاصل جمع عدد سوم با پنجم 14 است.

(5) حاصل جمع این پنج عدد 30 است .


#include<stdio.h>

#include<conio.h>


void main ()
{
    int x1 ,x2 , x3 , x4 , x5 ;
   for (x1 = 1 ; x1<10 ;x1++)
       for (x2 =0 ;x2<10 ;x2++) {
          if (x1 != 2*x2-1) continue ;
         for (x3 =0 ; x3 <10;x3++)  {
             if (x2 + x3 != 10) continue;
            for (x4 =0 ; x4 <10 ;x4++) {
                if (x4 != x2+1) continue ;
               for (x5 = 0 ; x5 <10 ; x5++) {
                   if (x5+x3 != 14) continue ;
                  if (x1+x2+x3+x4+x5 != 30) continue ;
                  printf("%d%d%d%d%d" , x1 ,x2 ,x3 ,x4 ,x5);
                  getch();
                  }
               }
           }
        }

 }

سورس کد یافتن max به زبان c

با این برنامه می توانید مقدار ماکزیمم را از بین سه عدد پیدا کرد

این برنامه به زبان c نوشته شده است


#include<stdio.h>
#include<conio.h>

int main ()
{
    int a,b,c,max;
   printf ("please enter 3 number:");
   scanf("%d%d%d",&a,&b,&c);
   max=a;
   if (b>max)
       max=b;
   if (c>max)
       max=c;
   printf ("%d",max);
   getch();

}