conversor online python para C
console.log("Hello World!");
Good Grasshopper
console.log("Hello World!");
#include<stdio.h>
int isprime(int); /* function prototype */
int main()
{
int i, j, num, count, row_rount, column_count, n, m, p;
printf("input n and m"); /* n=no.of rows m=no.of columns */
scanf("%d%d",&n,&m);
int a[n][m];
printf("enter elements of matrix");
for(i=0;i<n;i++) /* reading matrix elements */
{
for(j=0;j<m;j++)
{
scanf("%d",&a[i][j]);
}
}
row_rount=10000;
column_count=10000;
for(i=0;i<n;i++)
{
count=0;
for(j=0;j<m;j++)
{
num=a[i][j];
p=isprime(num);
while(p==0) /* if not prime */
{
num++;
count++;
p=isprime(num);
}
}
if(count<row_rount)
{
row_rount=count;
}
}
for(j=0;j<m;j++)
{
count=0;
for(i=0;i<n;i++)
{ num=a[i][j];
p=isprime(num);
while(p==0) /* if not prime */
{
num++;
count++;
p=isprime(num);
}
}
if(count<column_count)
{
column_count=count;
}
}
if(row_rount<column_count)
printf("%d",row_rount);
else printf("%d",column_count);
return 0;
}
int isprime(int num)
{
int prime[30]={0};
int i,x;
prime[0]=2;
prime[1]=3;
if(num==1)
return 0;
else if((num==2)||(num==3))
return 1;
else
{
i=0;x=1;
while((prime[i])!=0)
{
if(num%prime[i]==0)
x=0;
i++;
}
if(x==1)
return 1;
else return 0;
}
}
#include<stdio.h>
#include<stdlib.h>
struct node
{
int data;
struct node* next;
};
struct node *f = NULL;
struct node *r = NULL;
void enqueue(int d) //Insert elements in Queue
{
struct node* n;
n = (struct node*)malloc(sizeof(struct node));
n->data = d;
n->next = NULL;
if((r==NULL)&&(f==NULL))
{
f = r = n;
r->next = f;
}
else
{
r->next = n;
r = n;
n->next = f;
}
}
void dequeue() // Delete an element from Queue
{
struct node* t;
t = f;
if((f==NULL)&&(r==NULL))
printf("\nQueue is Empty");
else if(f == r){
f = r = NULL;
free(t);
}
else{
f = f->next;
r->next = f;
free(t);
}
}
void print(){ // Print the elements of Queue
struct node* t;
t = f;
if((f==NULL)&&(r==NULL))
printf("\nQueue is Empty");
else{
do{
printf("\n%d",t->data);
t = t->next;
}while(t != f);
}
}
int main()
{
int opt,n,i,data;
printf("Enter Your Choice:-");
do{
printf("\n\n1 for Insert the Data in Queue\n2 for show the Data in Queue \n3 for Delete the data from the Queue\n0 for Exit");
scanf("%d",&opt);
switch(opt){
case 1:
printf("\nEnter the number of data");
scanf("%d",&n);
printf("\nEnter your data");
i=0;
while(i<n){
scanf("%d",&data);
enqueue(data);
i++;
}
break;
case 2:
print();
break;
case 3:
dequeue();
break;
case 0:
break;
default:
printf("\nIncorrect Choice");
}
}while(opt!=0);
return 0;
}
#include<stdio.h>
#include<stdlib.h>
struct node
{
int data;
struct node* next;
};
struct node *f = NULL;
struct node *r = NULL;
void enqueue(int d) //Insert elements in Queue
{
struct node* n;
n = (struct node*)malloc(sizeof(struct node));
n->data = d;
n->next = NULL;
if((r==NULL)&&(f==NULL))
{
f = r = n;
r->next = f;
}
else
{
r->next = n;
r = n;
n->next = f;
}
}
void dequeue() // Delete an element from Queue
{
struct node* t;
t = f;
if((f==NULL)&&(r==NULL))
printf("\nQueue is Empty");
else if(f == r){
f = r = NULL;
free(t);
}
else{
f = f->next;
r->next = f;
free(t);
}
}
void print(){ // Print the elements of Queue
struct node* t;
t = f;
if((f==NULL)&&(r==NULL))
printf("\nQueue is Empty");
else{
do{
printf("\n%d",t->data);
t = t->next;
}while(t != f);
}
}
int main()
{
int opt,n,i,data;
printf("Enter Your Choice:-");
do{
printf("\n\n1 for Insert the Data in Queue\n2 for show the Data in Queue \n3 for Delete the data from the Queue\n0 for Exit");
scanf("%d",&opt);
switch(opt){
case 1:
printf("\nEnter the number of data");
scanf("%d",&n);
printf("\nEnter your data");
i=0;
while(i<n){
scanf("%d",&data);
enqueue(data);
i++;
}
break;
case 2:
print();
break;
case 3:
dequeue();
break;
case 0:
break;
default:
printf("\nIncorrect Choice");
}
}while(opt!=0);
return 0;
}
#include<stdio.h>
#include<math.h>
#include<conio.h>
void dummy()
{
float f,*fp;
fp=&f;
}
void main()
{
int Lval1[5],Lval2[5],Lval3[5],Lval4[5],Lval5[5],w[5];
float RS[40];
int i,j,k;
clrscr();
printf("\n Enter the linguistic variable values for Lval 1\n");
for(j=1;j<=5;j++)
{
scanf("%d",&Lval1[j]);
}
printf("\n Enter the linguistic variable values for Lval 2\n");
for(j=1;j<=5;j++)
{
scanf("%d",&Lval2[j]);
}
printf("\n Enter the linguistic variable values for Lval 3\n");
for(j=1;j<=5;j++)
{
scanf("%d",&Lval3[j]);
}
printf("\n Enter the linguistic variable values for Lval 4\n");
for(j=1;j<=5;j++)
{
scanf("%d",&Lval4[j]);
}
printf("\n Enter the linguistic variable values for Lval 5\n");
for(j=1;j<=5;j++)
{
scanf("%d",&Lval5[j]);
}
printf("\n Enter the weight values wt\n");
for(k=1;k<=5;k++)
{
scanf("%d",&w[j]);
}
for(i=1;i<=25;i++)
{
for(j=1;j<=5;j++)
{
for(k=1;k<=5;k++)
{
RS[i]=((w[k]*Lval1[j])+(w[k+1]*Lval2[j])+(w[k+2]*Lval3[j])+(w[k+3]*Lval4[j])+(w[k+4]*Lval5[j]))/(w[k]+w[k+1]+w[k+2]+w[k+3]+w[k+4]);
}
}
}
for(i=1;i<=25;i++)
{
printf("\nThe rule strength computed RS[%d]=%.2f\n",i,RS[i]);
}
getch();
}