求个简单小程序
急求一个小程序:
要求输入一个一百位以上的数字n,求n的e次方再除以d的余数
其中n可以用随机数获取(输入一个种子),e和d是自己输入的数字
有界面的再送100分
界面至少有三个框框,分别输入三个数,有一个按钮用来求值
/**********************************************/
/*****************求n^e%d的值******************/
/************要求n可以達到百位****************/
/**********************************************/
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <stdlib.h>
main()
{
double a,b,d,r1,r2;
unsigned n;
int e;
/*clrscr();*/
printf("please input n:");
scanf("%d",&n);
r1=(int)rand(n); /* 獲取隨機數 */
r2=(int)rand(n);
printf("please input e:");
scanf("%d",&e);
printf("please input d:");
scanf("%lf",&d);
/*a=pow(n,e);*/
if(d==0)
printf("wrong input!");
b=fmod(pow(r1,(int)r2),d); /* 用兩個隨機數的乘積獲取一個上百位的數字,然后對d求余. */
printf("%d^%d mod %lf = %f\n",n,e,d,b);
}
double getRan(unsigned d)
{
double r;
srand(d);
r=rand();
return r;
}